baconbeastnz Posted June 15, 2009 Share Posted June 15, 2009 So my PHP can't upload files through a form. tmp_name is empty, and the file isn't being created in the specific temp directory (from php.ini). Has anyone resolved this issue before? I've done alot of googling but cannot find a fix, despite the number of posts out there concerning this issue... Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/ Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 And why do you think this is a IIS problem ? I'll move this to the PHP help, but also you will need to post your form and PHP code.. the problem is likely in the form, check the METHOD is POST and the ENCTYPE is multipart/form-data Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856574 Share on other sites More sharing options...
baconbeastnz Posted June 15, 2009 Author Share Posted June 15, 2009 OK update. This error is occuring on my local setup. The exact code works on my live setup but is showing a move_uploaded_file error. ) probably unrelated) So the form is fine, the php code is fine. It's some whacked out IIS permission error. Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856610 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 Would you like to share the error? here is a quick todo. 1) Once you have created subdirectories "uploads/" in the same directory wher you code is running use the code from oportocala above and to make absolutely sure sure that the file you are trying to right is written under that folder. ( I recomend printing it using echo $uploadfile; ) 2) In windows explorer browse to the upload directory created above and share it. To do that execute the following substeps. a) Right click the folder click "sharing and security..." b) Check 'Share this folder on the network' c) Check 'Allow network users to change my files' ( THIS STEP IS VERY IMPORTANT ) d) click 'ok' or 'apply' 3) you can then go in the IIS to set read and write permissions for it. To do that execute the followin substeps. a) Open IIS (Start/Controp Panel (classic View)/ Admistrative tools/Internet Information Service b) Browse to your folder (the one we created above) c) right click and select properties. d) in the Directory tab, make sure, READ, WRITE, AND DIRECTORY BROWSING are checked. e) For the security freaks out there, You should also make sure that 'execute permissions:' are set to Script only or lower (DO NOT SET IT TO 'script and executable)'( that is because someone could upload a script to your directory and run it. And, boy, you do not want that to happen). Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856614 Share on other sites More sharing options...
baconbeastnz Posted June 15, 2009 Author Share Posted June 15, 2009 well there's no error on my local machine. if(move_uploaded_file($_FILES["1"]['tmp_name'], $_FILES["file"]["name"])) is not firing. tmp_name is blank tmp_Error is 0 I've set the tmp file upload folder in php ini and set all permissions on for all users ( including IIS user ) and the file is not being created in there. --- The error on the active server is: (unrelated) Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpK20iIC' to '' in /home/content/b/a/c/baconbeastnz/html/top_php.php on line 313 EDIT: Am trying the stuff you quoted in. thanks for that! will get back to you soon. Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856625 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 that line is wrong surely it should be if(move_uploaded_file($_FILES["file"]['tmp_name'], $_FILES["file"]["name"]) of course that depends on the form! Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856628 Share on other sites More sharing options...
baconbeastnz Posted June 15, 2009 Author Share Posted June 15, 2009 "1" is the name of the first file upload form e.g <input name="1" type="file"> So should be ok? Just tried that stuff you quoted in, it hasn't fixed the issue. Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856633 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 okay so $_FILES["file"]["name"] should be $_FILES["1"]["name"] also ! Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856634 Share on other sites More sharing options...
baconbeastnz Posted June 15, 2009 Author Share Posted June 15, 2009 Ahya! Haha thanks. That was pretty tired, think I have been coding too long today. Once you past 8 hours things start to slow down lol. So now its working on the live site!! Hmm I'll try and fix it on the local site and post the Solution and label it solved Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856650 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 yep that's a kick yourself error okay well let us know the outcome Quote Link to comment https://forums.phpfreaks.com/topic/162286-php-cant-upload-files-through-form/#findComment-856655 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.