Hi Everyone, I have the following script and I would like to rename the uploaded file to web-image(ext)
The file is being uploaded to the correct location on the server and the database is being updated correctly, But I am unable to figure out how to rename the uploaded file with the correct ext of .jpg or .png
$img1 = $_FILES['web_image']['name'];
//let's add a security check, to make sure only allowed files are uploaded
$ext=explode('.',$img1);//explode the image name into an array to get the extension
$allowed_exts=array('jpg','jpeg','png');// allowed extensions, add or remove any extension you want allowed(LOWER CASE ONLY)
if(in_array(strtolower($ext[1]), $allowed_exts)){//file type is allowed!
// store image
$dest="product-imgs/$productid/tmp_".$img1;
$val= move_uploaded_file($_FILES['web_image']['tmp_name'], $dest);
chmod($dest, 0644);//make sure you have permissions for the file
if($val)
{
//update database and rename
$filename = $_FILES['web_image']['tmp_name'];
imageResizes($dest,'product-imgs/'.$productid.'/web_image.jpg',strtolower($ext[1]));
Hoping someone can help.
thanks