function upload_image()
{
if(isset($_FILES['user_image']))
{
// Count total files
$countfiles = count($_FILES['user_image']['name']);
for($i=0;$i<$countfiles;$i++){
$extension = explode('.', $_FILES['user_image']['name'][$i]);
$new_name = rand() . '.' . $extension[1];
$destination = '../portfolio/upload/' . $new_name;
$thimbDestination = '../portfolio/upload/thumb/' . $new_name;
move_uploaded_file($_FILES['user_image']['tmp_name'][$i], $destination);
imageResize($destination, 300);
$file_tmp = $_FILES['user_image']['tmp_name'][$i];
copy($file_tmp, $thimbDestination);
}
return $new_name;
}
}
function imageResize($file_path, $new_width){
//Получаем ширину и высоту исходника
list($w, $h) = getimagesize($file_path);
//Получаем коэфицент соотношения сторон
$proportions = $h / $w;
$new_w = $new_width;
$new_h = $new_w * $proportions; // Получаем высоту уменьшенной картинки пропорционально новой ширине
$thumb = imagecreatetruecolor($new_w, $new_h);
$source = imagecreatefromjpeg($file_path);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $new_w, $new_h, $w, $h);
imagejpeg($thumb, $_FILES['user_image']['tmp_name']);
return $_FILES['user_image']['tmp_name'];
imagedestroy($thumb);
}
function upload_image()
{
if(isset($_FILES['user_image']))
{
for($i=0;$i<count($_FILES["user_image"]["name"]);$i++){
$extension = explode('.', $_FILES['user_image']['name'][$i]);
$new_name = rand() . '.' . $extension[1];
$destination = '../portfolio/upload/' . $new_name;
$thimbDestination = '../portfolio/upload/thumb/' . $new_name;
move_uploaded_file($_FILES['user_image']['tmp_name'][$i], $destination);
imageResize($destination, 300);
$file_tmp = $_FILES['user_image']['tmp_name'][$i];
copy($file_tmp, $thimbDestination);
return $new_name;
}
}
}
function imageResize($file_path, $new_width){
//Получаем ширину и высоту исходника
list($w, $h) = getimagesize($file_path);
//Получаем коэфицент соотношения сторон
$proportions = $h / $w;
$new_w = $new_width;
$new_h = $new_w * $proportions; // Получаем высоту уменьшенной картинки пропорционально новой ширине
$thumb = imagecreatetruecolor($new_w, $new_h);
$source = imagecreatefromjpeg($file_path);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $new_w, $new_h, $w, $h);
imagejpeg($thumb, $_FILES['user_image']['tmp_name']);
return $_FILES['user_image']['tmp_name'];
imagedestroy($thumb);
}
function upload_image()
{
if(isset($_FILES['user_image']))
{
$extension = explode('.', $_FILES['user_image']['name']);
$new_name = rand() . '.' . $extension[1];
$destination = '../reviews/upload/' . $new_name;
$thimbDestination = '../reviews/upload/thumb/' . $new_name;
move_uploaded_file($_FILES['user_image']['tmp_name'], $destination);
$v = var_dump(imageResize($destination, 300));
return $v;
}
}
function upload_image()
{
if(isset($_FILES['user_image']))
{
$extension = explode('.', $_FILES['user_image']['name']);
$new_name = rand() . '.' . $extension[1];
$destination = '../reviews/upload/' . $new_name;
$thimbDestination = '../reviews/upload/thumb/' . $new_name;
move_uploaded_file($_FILES['user_image']['tmp_name'], $destination);
var_dump($thumb = imageResize($destination, 300));
copy($thumb, $thimbDestination);
return var_dump;
}
}
$thumb = imageResize($destination, 300);
copy($thumb, $thimbDestination);
function upload_image()
{
if(isset($_FILES['user_image']))
{
$extension = explode('.', $_FILES['user_image']['name']);
$new_name = rand() . '.' . $extension[1];
$destination = '../reviews/upload/' . $new_name;
$thimbDestination = '../reviews/upload/thumb/';
move_uploaded_file($_FILES['user_image']['tmp_name'], $destination);
$thumb = imageResize($destination, 300);
copy($thumb, $thimbDestination);
return $new_name;
}
}