abqphotog Posted August 7, 2014 Share Posted August 7, 2014 I have searched everywhere for a "how to" for this. I need to be able to rename an uploaded file with data from form fields. For example, I have "catagory", "class" and "title" fields. I need the uploaded file (jpeg) to be renamed with the contents of these three fields. The form info is also stored in a database. Thanks, Darrel Link to comment Share on other sites More sharing options...
HartleySan Posted August 7, 2014 Share Posted August 7, 2014 You need to use the move_uploaded_file function to both name the file and specify the file path for the file. Details on the function can be found here: http://php.net/manual/en/function.move-uploaded-file.php Basically, post the form, and in the PHP script that is called from the form post, used the specified values to name the file. For example: move_uploaded_file($tmp_file, "/uploads/file_{$_POST['category']}_{$_POST['class']}_{$_POST['title']}"); Link to comment Share on other sites More sharing options...
abqphotog Posted August 7, 2014 Author Share Posted August 7, 2014 Thanks! I found tuts on moving and renaming, but I didn't know how to apply the form field contents. ~Darrel Link to comment Share on other sites More sharing options...
Larry Posted August 8, 2014 Share Posted August 8, 2014 You would just dynamically generate the new file name using the form data by accessing the form data as you would any form data. Link to comment Share on other sites More sharing options...
Recommended Posts