AzaraelIshanti Posted August 12, 2009 Share Posted August 12, 2009 I think this forum is the best fit for this topic... I've been coding in PHP for the better part of 2 years now and have a rudimentary grasp of what's going on. I recently was asked to administrate a friend's new Red Hat-based virtual server from GoDaddy, and things have been going swimmingly...until I attempted to hook in a PHP file upload, only to find that it will not move the files to the specified destination. I'm getting an error of 0 for the $_FILES array, and when I run the script locally, it successfully move_uploaded_file() to the correct location (running Windows/WAMP Stack locally). However, duplicating this on the virtual server, there is no error or warning of any kind from move_uploaded_file(), it simply is not showing up in the correct directory. I've checked capitalization, I'm completely stumped. I figure it's probably not a fault with PHP, as I've scoured the php.ini file and found all references to File Upload to be ON. It probably has something to do with directory permissions in Linux, but I'm still a novice at all that. Any and all suggestions/help would be greatly appreciated. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/ Share on other sites More sharing options...
wildteen88 Posted August 12, 2009 Share Posted August 12, 2009 The folder your trying to upload the files to most probably doesn't have sufficient permissions for writing. Add the following at the top of your script if(is_writable('/path/to/upload/folder/') { echo 'Folder is writeable'; } else { echo 'Folder is not writeable'; } And run it on your red-hat server. What is the output? If its says not writeable then change the permissions of the folder to 0777 Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896598 Share on other sites More sharing options...
AzaraelIshanti Posted August 12, 2009 Author Share Posted August 12, 2009 I ran the script (you forgot a right parenthesis, btw, took me 5 minutes to figure out why it wouldn't run ). It was not writable. So I SSH into the server, I "chmod -R 0777 /path/to/webpage/root" (obviously with the correct path...) because there are a number of directories that need to be able to upload into, and the script says it is now writable. ....however the files are still not showing up after upload. Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896834 Share on other sites More sharing options...
play_ Posted August 12, 2009 Share Posted August 12, 2009 And you still get the same error code? Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896839 Share on other sites More sharing options...
AzaraelIshanti Posted August 12, 2009 Author Share Posted August 12, 2009 I've never gotton any errors of any kind, that's what baffled me. I have it spilling output trying to debut it. print_r($_FILES); no errors I'm outputting the $path, $filename, etc, everything is correct, and the script runs with no issues locally on the Wamp stack. Just once I upload, it won't work. I did the chmod and the is_writable() now says all the directories are writable...but still nothing. Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896841 Share on other sites More sharing options...
play_ Posted August 13, 2009 Share Posted August 13, 2009 Then no idea. Maybe the group it belongs to? maybe if someone here has godaddy they can test your script for you. Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896851 Share on other sites More sharing options...
AzaraelIshanti Posted August 13, 2009 Author Share Posted August 13, 2009 I figure it might have something to do with it being the wrong group. GoDaddy has CPanel which allows you to add a "Domain" to the server. I addded the domain, and it created a new account with FTP permissions and such to the root HTML page and made that root folder the default folder when you go to the site itself, etc etc. What group should it be set to and how can I check if that's what it is or is not set to? Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896856 Share on other sites More sharing options...
play_ Posted August 13, 2009 Share Posted August 13, 2009 Sorry man, this is as far as i can help you. google the hell out of google and you might find something Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896861 Share on other sites More sharing options...
AzaraelIshanti Posted August 13, 2009 Author Share Posted August 13, 2009 I'm trying to determine exactly WHERE the problem is occuring. print_r($_FILES); produces: Array ( [new_file] => Array ( [name] => geico_eyes.png [type] => image/x-png [tmp_name] => /tmp/phpjnTbKx [error] => 0 [size] => 12831 ) ) Does error = 0 mean it successfully arrived at /tmp/phpjnTbKx? Or does error 0 mean it received all the information and it SHOULD be in /tmp/phpjnTbKx?? Consequently, if the file cannot be moved via move_uploaded_file() should there be some kind of error or warning associated with it being the wrong permissions? I get no warnings or errors at all...where did it go wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896886 Share on other sites More sharing options...
AzaraelIshanti Posted August 13, 2009 Author Share Posted August 13, 2009 Somebody mark this as solved, as I'm a complete moron. I believe it was the initial chmod recommended in post #2 of this thread that solved the problem, but as I had complete bungled the original script trying to fix it in the first place, it wasn't working due to my own stupidity. I went through the code top to bottom and found some very stupid mistakes in regards to paths (what was I thinking...?) and it again works. Thank you for all your help and bearing with me. So yea, mark as solved or something... And for future posters...check your destination paths. Wish I had... Quote Link to comment https://forums.phpfreaks.com/topic/169957-solved-php-file-upload/#findComment-896897 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.