Crash2108 Posted June 17, 2007 Share Posted June 17, 2007 This scrupt is to upload a file, and as far as I can tel, and all of the examples around uploading, there is nothing wrong with it. But it doesn't work and can't move the file. if(!$_POST==NULL || $_POST=='') { $new_name = $_POST['name'].$_FILES['userfile']['name']; if ( $_FILES['userfile']['size'] > $MAX_SIZE) {$message = "The file size is over 2MB.";} else { $message = 'done'; copy ($_FILES['userfile']['tmp_name'], $new_name) or die ("Could not copy"); //move_uploaded_file($_FILES['userfile']['tmp_name'], $new_name); mysql_query("INSERT INTO cart_products VALUES ('$_POST[name]', $_POST[price], '$_POST[desc]', '')"); } } Quote Link to comment https://forums.phpfreaks.com/topic/55928-i-dont-see-whats-wrong-with-this-uploading-of-a-file/ Share on other sites More sharing options...
paul2463 Posted June 17, 2007 Share Posted June 17, 2007 as far as I know the name of the file you wish to copy it to, requires a file extension so copy knows what type of file to save it to such as <?php $file = 'example.txt'; $newfile = 'example2.txt'; //without the full filename and extension it wont copy if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> so you need to append a file extension to your $new_name such as .jpeg or some such whatever the file may be Quote Link to comment https://forums.phpfreaks.com/topic/55928-i-dont-see-whats-wrong-with-this-uploading-of-a-file/#findComment-276213 Share on other sites More sharing options...
Crash2108 Posted June 17, 2007 Author Share Posted June 17, 2007 I tried that, it didn't work. I tried PHP.net's upload example, that didn't work. I tried another upload script I had, and it finally gave me some information I could use. It was simply another stupid error that wastes a couple hours of your life. I forgot to give that directory permissions to change files... I have to go back and backtrack all of the different codes I tried and try to get the best one working for my project and make up for lost time now... Quote Link to comment https://forums.phpfreaks.com/topic/55928-i-dont-see-whats-wrong-with-this-uploading-of-a-file/#findComment-276450 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 I think this is something that causes you some error //move_uploaded_file($_FILES['userfile']['tmp_name'], $new_name); =====$new_name====== this variable should a location or a folder that the uploaded file should go rest are still confuse me maybe you try this first and ask me if there's still error Quote Link to comment https://forums.phpfreaks.com/topic/55928-i-dont-see-whats-wrong-with-this-uploading-of-a-file/#findComment-276501 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.