dpiearcy Posted January 7, 2013 Share Posted January 7, 2013 I use this all the time and even in a few other places at the same site. This one is a sub folder but that shouldn't make a difference I wouldn't think. Simple uploading an image. I'm just going to post the form, the first part with error check because that's where it stops. My first IF kicks in and tells me I don't have anything selected. I changed my form to GET and see the name of the file in my URL. I've also changed it back to post and then just sent it to a php that echoed the results and see the name of the image. So it has to be in the temp folder section. Form: <form action="pic_upload_parse.php" method="post"> <input name="uploaded_file" type="file" /> <input name="submit" type="submit" value="Upload" /> </form> PHP parse code: $fileName = $_FILES["uploaded_file"]["name"]; $fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; $fileType = $_FILES["uploaded_file"]["type"]; $fileSize = $_FILES["uploaded_file"]["size"]; $fileErrorMsg = $_FILES["uploaded_file"]["error"]; $kaboom = explode(".", $fileName); $fileExt = end($kaboom); // START PHP Image Upload Error Handling -------------------------------------------------- if (!$fileTmpLoc) { echo "ERROR: Please browse for a file before clicking the upload button."; exit(); I'll save all the else if's checking size of file and matches for .jpg|.gif etc. since I'm not getting past this first error anyway. For some reason not seeing the file in the temp php. Link to comment https://forums.phpfreaks.com/topic/272812-dont-know-why-this-isnt-working/ Share on other sites More sharing options...
cpd Posted January 7, 2013 Share Posted January 7, 2013 Have you tried dumping the $_FILES variable to see if it contains anything? Link to comment https://forums.phpfreaks.com/topic/272812-dont-know-why-this-isnt-working/#findComment-1404036 Share on other sites More sharing options...
dpiearcy Posted January 7, 2013 Author Share Posted January 7, 2013 Have you tried dumping the $_FILES variable to see if it contains anything? Nope. Had not done that but thought that a good idea. Had nothing. So I looked at my form again and added the enctype="multipart/form-data" And then it uploaded correctly. Knew I was forgetting something. One of these days I'm going to just save these little code snippets on my computer so I don't do stupid stuff any longer (or less frequently I should say). Thanks cpd. Got me seeing nothing there and that helped. Link to comment https://forums.phpfreaks.com/topic/272812-dont-know-why-this-isnt-working/#findComment-1404038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.