I would like to change the name of files uploaded, for example if i choose to upload file "image.png" i would like to rename this to "face.png" when uploaded.
I have a php image upload form, however it keeps the current name of the file and uploads it, I for now would like a variable name $custom_name which i can edit the contents and this is the new name of the file.
PHP UPLOAD FORM :
if(isset($_FILES['image'])){
$errors= array();
$custom_name = ""; // THIS IS WHERE I WANT TO INSERT NEW NAME
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("png");
if(in_array($file_ext,$expensions)=== false){
$errors[]='Only PNG files';
echo "Only PNG files";
}
if($file_size > 2097152){
$errors[]='Larger than 2MB';
echo "Larger than 2MB";
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/quads/".$file_name);
echo "Success";
}else{
}
}
I have tried concatenation however just dont know where to place the $custom_name variable.
Thankyou very much for any help