npsari Posted September 14, 2007 Share Posted September 14, 2007 Hello there everyone, I am using this code to rename all images which are uploaded to $ImageName but the code doesnt work! What did i do wrong guys? $target_path = "images/"; $target_path = $target_path . basename( $_FILES['Image1']['name']); $_FILES['Image1']['tmp_name']; $target_path = "images/"; $filename = basename( $_FILES['Image1']['name']); $filename2 = $ImageName; $target_path .= $filename2; if(move_uploaded_file($_FILES['Image1']['tmp_name'], $target_path)) { echo "Image1: was uploaded successfully!"; } else{ print"Image1: could not be uploaded!"; } Quote Link to comment https://forums.phpfreaks.com/topic/69396-solved-rename-uploaded-images/ Share on other sites More sharing options...
Solarpitch Posted September 14, 2007 Share Posted September 14, 2007 Why not just do... $newname = "testfile"; $filename = $_FILES['Image1']['tmp_name']; $filename = $newname; if(move_uploaded_file($filename, $target_path)) Quote Link to comment https://forums.phpfreaks.com/topic/69396-solved-rename-uploaded-images/#findComment-348666 Share on other sites More sharing options...
npsari Posted September 14, 2007 Author Share Posted September 14, 2007 So, you mean it will be like this? $target_path = "images/"; $target_path = $target_path . basename( $_FILES['Image1']['name']); $_FILES['Image1']['tmp_name']; $target_path = "images/"; $newname = "testfile"; $filename = $_FILES['Image1']['tmp_name']; $filename = $newname; if(move_uploaded_file($filename, $target_path)) echo "Image1: was uploaded successfully!"; } else{ print"Image1: could not be uploaded!"; } Am i right? If not, can you arrange it for me please, because iam confused Quote Link to comment https://forums.phpfreaks.com/topic/69396-solved-rename-uploaded-images/#findComment-348667 Share on other sites More sharing options...
Solarpitch Posted September 14, 2007 Share Posted September 14, 2007 Modify that with your own variables now and see how it works. It just depends on how you want to rename the files. Quote Link to comment https://forums.phpfreaks.com/topic/69396-solved-rename-uploaded-images/#findComment-348671 Share on other sites More sharing options...
npsari Posted September 14, 2007 Author Share Posted September 14, 2007 thank you, i will work on it Quote Link to comment https://forums.phpfreaks.com/topic/69396-solved-rename-uploaded-images/#findComment-348680 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.