cs1h Posted September 25, 2008 Share Posted September 25, 2008 Hi, I have written a script to upload a file and change it's name before saving. the code is <?php $password = createRandomPassword(); $image = $_FILES['photo']['name']; $ext = substr($image, strrpos($image, '.') + 1); $target = "image_convert/"; $newName = $target . "$password.$ext"; if ($_FILES['photo']['tmp_name']) { $finalName = $newName; } else { $finalName = $target . "dfxfd.jpg"; } if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $finalName)) { echo "The file has been uploaded as $finalName"; } else { echo "Sorry, there was a problem uploading your file."; } ?> But the problem is that it always returns the message Sorry, there was a problem uploading your file. Can anyone see why this may be? Thanks, Colin Link to comment https://forums.phpfreaks.com/topic/125869-solved-unknown-file-upload-issue/ Share on other sites More sharing options...
cs1h Posted September 25, 2008 Author Share Posted September 25, 2008 Sorry I made a stupid mistake, I put the photo in here $_FILES['photo']['name']; instead of image Link to comment https://forums.phpfreaks.com/topic/125869-solved-unknown-file-upload-issue/#findComment-650861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.