Glese Posted November 30, 2011 Share Posted November 30, 2011 After the file gets uploaded, I intend the file to become renamed, and then moved to its destination folder. Though to move the file, I need the newly renamed file name and also its location, which is the temporary folder, and the latter describes my question. This is the script as follows: $avatar_tmp = $_FILES['avatar_upload']['tmp_name']; // Rename the file into a more usable file name $new_file_name = $user_name . '_' . rand(111111, 999999) . '.jpg'; rename($avatar_tmp, $new_file_name); // Move the uploaded file on the disk to its folder // The directory of the temporary folder is needed in front of the new_file_name variable move_uploaded_file ($new_file_name, $target); The directory of the temporary folder is needed in front of the new_file_name variable and my question is, is there any function, to get the directory of the temporary folder for the uploaded file? So I can insert it in front of the new_file_name variable and move it out of the folder to its destination folder? Link to comment https://forums.phpfreaks.com/topic/252094-get-the-temporary-directory-of-the-uploaded-file/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2011 Share Posted November 30, 2011 You rename the file when you use the move_uploaded_file statement to move the file to the destination. $target would contain the destination folder and the final name for the file. Link to comment https://forums.phpfreaks.com/topic/252094-get-the-temporary-directory-of-the-uploaded-file/#findComment-1292483 Share on other sites More sharing options...
Glese Posted November 30, 2011 Author Share Posted November 30, 2011 Thanks for the tip, it works. Link to comment https://forums.phpfreaks.com/topic/252094-get-the-temporary-directory-of-the-uploaded-file/#findComment-1292488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.