php - Rename image on upload -


i rename image when uploaded.

the url of upload page upload.php?clientid=123456 , save image 123456.jpg

here upload code

   if (move_uploaded_file($_files["filetoupload"]["tmp_name"], $target_file)) {     echo "the file ". basename( $_files["filetoupload"]["name"]). " has been uploaded."; } else {     echo "sorry, there error uploading file."; } 

is possible?

(newbie)

you're saving file:

move_uploaded_file($_files["filetoupload"]["tmp_name"], $target_file) 

just first set $target_file whatever want name of file be.

$target_file = "/some/path/to/a/file.jpg"; 

or

$target_file = "/some/path/with/a/$variable.jpg"; 

the move_uploaded_file() function going save (or @ least try to) file whatever name in second function parameter. provide name want file have.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -