ngreenwood6 Posted March 16, 2009 Share Posted March 16, 2009 I know quite a bit about php but I have never done and file uploading. I have created these two files: index.html <html> <title>Upload File</title> <body> <form enctype="multipart/form-data" action="uploaded.php" method="POST"> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> </body> </html> and uploaded.php <html> <title>Uploaded File</title> <body> <?php $target_path = "videos/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded as a ". basename($_FILES['uploadedfile']['type']) . ""; } else{ echo "There was an error uploading the file, please try again!"; } ?> </body> </html> The code is working. However, whenever I try to upload a video using this method it just gives me an index undefined error. I am not sure if it is because of the type or if it is the file size because the file is about 20MB. I can upload smaller files and of a different format. The error is: Notice: Undefined index: uploadedfile in C:\wamp\www\upload\uploaded.php on line 8 Notice: Undefined index: uploadedfile in C:\wamp\www\upload\uploaded.php on line 10 There was an error uploading the file, please try again! Any help is appreciated. EDIT: I forgot to mention that I changed the post_max_size in the php.ini file like this: post_max_size = 80000M and upload_max_file_size too. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 16, 2009 Share Posted March 16, 2009 EDIT: I forgot to mention that I changed the post_max_size in the php.ini file like this: post_max_size = 80000M and upload_max_file_size too. Yes, but did you stop and start your web server to get any changed made to php.ini to take effect or use a phpinfo(); statement to check what the actual values are? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 implement this in your code: http://us.php.net/manual/en/features.file-upload.errors.php#80575 you don't have to throw an exception, just use that array and test the value of the 'error' key in the array. that will tell you where it is failing. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted March 16, 2009 Author Share Posted March 16, 2009 @PFMaBiSmAd - Yes I did. @rhodesa - I am now getting this error lol: Notice: Undefined index: uploadedfile in C:\wamp\www\upload\uploaded.php on line 8 Notice: Undefined index: uploadedfile in C:\wamp\www\upload\uploaded.php on line 10 There was an error uploading the file, please try again! Notice: Undefined index: uploadedfile in C:\wamp\www\upload\uploaded.php on line 26 Fatal error: Uncaught exception 'Exception' with message 'Unknown error uploading file.' in C:\wamp\www\upload\uploaded.php:34 Stack trace: #0 {main} thrown in C:\wamp\www\upload\uploaded.php on line 34 Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 replace "uploadfile" in the script with whatever you named your FILE INPUT on your form Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted March 16, 2009 Author Share Posted March 16, 2009 What do you mean? I think I already did that. I tried uploading another video of the same type (.wmv) and it worked fine but it was less than 8MB and the other one that wont work is 15 MB. Any ideas? Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted March 16, 2009 Author Share Posted March 16, 2009 I guess wamp just wasnt resetting itself so I just restarted my computer and it worked fine. Thanks guys. Quote Link to comment 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.