thaidomizil Posted June 22, 2011 Share Posted June 22, 2011 Hello, i'm trying to create some file upload which renames the files automatically, the renamed file name needs to be the value from another text field, example: i have a file upload form, and a last name text input, after the file upload the file should be renamed to the value of the last name input. i really don't know where to start here, can anyone give me some hint / advice? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/240141-file-upload-rename-file-based-on-another-form-input/ Share on other sites More sharing options...
Psycho Posted June 22, 2011 Share Posted June 22, 2011 Do you have any working code for the file upload process at all? What you are asking for would be a highly trivial task with working code, so I assume not. There are countless "PHP Upload" tutorials on the next. Go find one and create an upload page. You should be able to easily figure out the rename part since you have to name the file when you save it anyway. Post back with any problems you have. If you just want someone to build it for you then you can post in the freelance forum. Quote Link to comment https://forums.phpfreaks.com/topic/240141-file-upload-rename-file-based-on-another-form-input/#findComment-1233483 Share on other sites More sharing options...
The Little Guy Posted June 22, 2011 Share Posted June 22, 2011 move_uploaded_file The line above "move_uploaded_file" get the name from the textbox named "last_name". <?php $uploads_dir = '/uploads'; foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_POST['last_name']; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/240141-file-upload-rename-file-based-on-another-form-input/#findComment-1233496 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.