Jump to content

Don't know why this isn't working...


dpiearcy

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.