justlukeyou Posted June 24, 2012 Share Posted June 24, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/ Share on other sites More sharing options...
requinix Posted June 24, 2012 Share Posted June 24, 2012 That error does not come from PHP. Your script is making it. So find out why your script is making it and fix the problem. If you need help doing that then post the code. Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1356664 Share on other sites More sharing options...
justlukeyou Posted June 26, 2012 Author Share Posted June 26, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357046 Share on other sites More sharing options...
PFMaBiSmAd Posted June 26, 2012 Share Posted June 26, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357087 Share on other sites More sharing options...
justlukeyou Posted June 27, 2012 Author Share Posted June 27, 2012 Thanks, So is there a 'standard' code for uploading images using PHP? Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357391 Share on other sites More sharing options...
marcus Posted June 27, 2012 Share Posted June 27, 2012 http://lmgtfy.com/?q=php+file+upload+tutorial Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357394 Share on other sites More sharing options...
justlukeyou Posted June 27, 2012 Author Share Posted June 27, 2012 Yeah, the second link is the one I tried which has been trashed as being useless. So which one is the best. I thought image upload would be widely used. Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357400 Share on other sites More sharing options...
justlukeyou Posted June 29, 2012 Author Share Posted June 29, 2012 This is ridiculous. There must be a reliable and safe image upload script. Quote Link to comment https://forums.phpfreaks.com/topic/264699-image-upload-script-tmp-folder-error/#findComment-1357983 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.