Jump to content

Image Upload Script (tmp folder error)


justlukeyou

Recommended Posts

Hi,

 

I am trying to get an image upload script working however it creates an error "Stored in: /tmp/php2r4dxH Invalid file "

 

I tried it originally without creating a tmp folder, then I created a tmp file and it still came up with this error.

 

Should I be creating the tmp folder myself or should my server have a setting which creates a tmp folder?

 

http://www.w3schools.com/php/php_file_upload.asp

Link to comment
Share on other sites

Thanks,

 

I have gone through it but I cant see where the issue is.  The code is copied the code directly from the W3 Schools website.

 

http://www.w3schools.com/php/php_file_upload.asp

 

I was hoping to get it working and then learn how it works.  Should it be creating a tmp folder in the root folder each time an image is upload or does an tmp folder already exist which I cant see.

Link to comment
Share on other sites

The code is copied the code directly from the W3 Schools website.

 

Obviously not. None of the three different pieces of php code from the w3schools site can produce the output you stated. Which of those three different pieces of php code are you using?

 

Without your actual code and the actual output you got from it, it's not possible to help you with what is wrong with your code.

 

Also, the last two pieces of code on the w3schools site are CRAP and should not be used for anything. It tests uploaded file information before it tests  for upload errors. If there is an upload error, the uploaded file information will be empty and the generic  "Invalid file" message will be displayed and you will never see the upload error output "Return Code: x" that would provide information about why the upload is failing.

 

The logic needs to test for upload errors first before it tries to use any of the uploaded file information.

 

Another glaring problem with that code is that is lumps together both the mime type and file size tests and outputs one common non-descriptive error message. When validating user input, you should never do that. Good validation code should have separate tests for each possible problem with the submitted data and output a separate, specific, descriptive message for each validation test that fails.

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.