robert_gsfame Posted October 7, 2009 Share Posted October 7, 2009 i just wanna ask whether is it possible to change the name of uploaded file, let say user has some file named "myfile1.JPG", and once he upload the file then the name will automatically change to "user1myfile.JPG".. Please give me some clue and code thx in advance Quote Link to comment https://forums.phpfreaks.com/topic/176788-solved-change-name-of-uploaded-file-help/ Share on other sites More sharing options...
mikesta707 Posted October 7, 2009 Share Posted October 7, 2009 with the moveuploadedfile() function, you can use a custom name as the file path. I'm going to guess you use the filename of the uploaded file in it. Well, you could instead use whatever you wanted. just do something like $target_path = "path/to/directory/".$username.$_FILE['file']['name']; if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_path)){ echo "success"; } else { echo "fail"; } Quote Link to comment https://forums.phpfreaks.com/topic/176788-solved-change-name-of-uploaded-file-help/#findComment-932116 Share on other sites More sharing options...
robert_gsfame Posted October 7, 2009 Author Share Posted October 7, 2009 thx so much !! got it!! Quote Link to comment https://forums.phpfreaks.com/topic/176788-solved-change-name-of-uploaded-file-help/#findComment-932130 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.