How to upload & Save Files with Desired name

You can try this,

$info = pathinfo($_FILES['userFile']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = "newname.".$ext; 

$target="images/".$newname;
move_uploaded_file( $_FILES['userFile']['tmp_name'], $target);

Leave a Comment