Open
include/functions.php
Find
PHP Code:
function upload_jpg($_FILES, $var_name, $file_name, $img_width = 128, $dir = "upload/", $rename = '')
{
if ($_FILES[$var_name]['name'])
{
$file_url = $dir . uniqid("") . tmp;
$ext = strrchr($_FILES[$var_name]['name'], '.');
move_uploaded_file($_FILES[$var_name]['tmp_name'], $file_url);
if ($_FILES[$var_name]['error'] > 0)
{
$err = 'Error occurs while uploading file';
}
else if (strtolower($ext) == '.jpg')
{
$img = @imagecreatefromjpeg($file_url);
$size = @getimagesize($file_url);
$width = $size[0];
$height = $size[1];
if ($width > $img_width)
{
$percentage = $img_width / $width;
$width *= $percentage;
$height *= $percentage;
$img_r = @imagecreatetruecolor($width, $height);
@imagecopyresampled($img_r, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
}
else
{
$img_r = $img;
}
$pic_name = $dir . $file_name;
@ImageJpeg($img_r, $pic_name, 100);
// rename("$pic_name", "$dir"."$rename");
@unlink($file_url);
}
else
{
@unlink($file_url);
$err = 'File must be as .jpg format';
}
}
return $err;
}
Replace With
PHP Code:
function upload_jpg($my_file, $var_name, $file_name, $img_width = 128, $dir = "upload/", $rename = '')
{
if ($my_file[$var_name]['name'])
{
$file_url = $dir . uniqid("") . tmp;
$ext = strrchr($my_file[$var_name]['name'], '.');
move_uploaded_file($my_file[$var_name]['tmp_name'], $file_url);
if ($my_file[$var_name]['error'] > 0)
{
$err = 'Error occurs while uploading file';
}
else if (strtolower($ext) == '.jpg')
{
$img = @imagecreatefromjpeg($file_url);
$size = @getimagesize($file_url);
$width = $size[0];
$height = $size[1];
if ($width > $img_width)
{
$percentage = $img_width / $width;
$width *= $percentage;
$height *= $percentage;
$img_r = @imagecreatetruecolor($width, $height);
@imagecopyresampled($img_r, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
}
else
{
$img_r = $img;
}
$pic_name = $dir . $file_name;
@ImageJpeg($img_r, $pic_name, 100);
// rename("$pic_name", "$dir"."$rename");
@unlink($file_url);
}
else
{
@unlink($file_url);
$err = 'File must be as .jpg format';
}
}
return $err;
}
Bookmarks