brown2005 Posted March 12, 2006 Share Posted March 12, 2006 I have a script that uploads a file from someones computer to my server.say the file i have is 3.JPGwhen 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 pleasetoplay: Edited title to be more meaningful. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 12, 2006 Share Posted March 12, 2006 Post the code that you use to determine the userid and the code that you use to save the uploaded file...please don't post your entire script...we only need the relevant parts. Quote Link to comment Share on other sites More sharing options...
k.soule Posted March 13, 2006 Share Posted March 13, 2006 $upload = move_uploaded_file($_FILES[u]['picture'][/u]['tmp_name'], "[u]/home/www/htdocs/[b]$id[/b].jpg[/u]");$_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.[i]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.[/i] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.