i am created one function to upload image with random name and it worked properly.
function f_upload($file_name, $path)
{
$ext=end(explode('.', $file_name['name']));
$f_name=rand().time().'.'.$ext;
if(move_uploaded_file($file_name['tmp_name'], $path.$f_name))
{
return $f_name;
}
else
{
return false;
}
}
now what i want is to create a thumb of same image with width of 75px on same directory but name start with t_imagename
i try this function but its giving error.
function f_upload_gallary($file_name, $path)
{
$ext=end(explode('.', $file_name['name']));
$f_name=rand().time().'.'.$ext;
if(move_uploaded_file($file_name['tmp_name'], $path.$f_name))
{
$src=$path.$f_name;
$desired_width=75;
$dest=$path;
$source_image = imagecreatefromjpeg($src);
$width = imagesx($source_image);
$height = imagesy($source_image);
$desired_height = floor($height*($desired_width/$width));
$virtual_image = imagecreatetruecolor($desired_width,$desired_height);
imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
imagejpeg($virtual_image,$dest);
return $f_name;
}
else
{
return false;
}
}
this function is not working.
i just want to create a thumb of 75 on same folder with name start with t_
Thanks
You didn’t specify the filename of destination image. Replace this line,
with this: