Rename of uploaded file
Posted 12 March 2006 - 10:08 PM
say the file i have is 3.JPG
when i upload it, i want to change the name of the file to 1.JPG or 2.JPG to conincide with the id of the person uuploading the image.
any ideas please
toplay: Edited title to be more meaningful.
Posted 12 March 2006 - 10:15 PM
Posted 13 March 2006 - 02:36 AM
$_FILES['picture']['tmp_name'] is the temporary name on the server, change picture to the name of the form element that you are uploading with.
/home/www/htdocs/$id.jpg is the location, change /home/www/htdocs/ to match your file system structure, $id would be the variable holding the identification of the person and, of course, .jpg is the extension. $upload will be 1, if the upload was successful.
EDIT -> Let me clarify the above, ['tmp_name'] should not be changed, it stands for the temporary name that the server is using to store the uploaded file, uploaded files are always moved to a temporary file and then moved to a permanent location. It doesn't pass the filename the user put in, if you wanted that name, it would just be ['name']...but that is useless unless you want to preserve the same file name; the only element of that code that will need changed is ['picture'] and the location and variable of the final location, as underlined above.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users