m1k3yb0y Posted May 18, 2012 Share Posted May 18, 2012 I have been spending the majority of this week figuring out why my files are not showing up at my upload location that I set up in my newly created simple upload form. It just seems like php doesn't like me at all. :'( Here is what my code looks like below. <?php if (move_uploaded_file($_FILES['thefile']['name'], $upload_file)) $destination = "/www/zymichost.com/m/t/l/mtlproductions/htdocs/"; $upload_file = $destination . basename($_FILES['thefile']['name']);{ echo "Your file has been uploaded successfully!"; }/* else { echo "Your file did not upload successfully. Check to make sure your file meets the requirements and then try again."; print_r($_FILES);}*/?> I have the orange marked areas commented out due to the unexpected T_ELSE error thing. What do I do to get my files to show up at my upload location when I use my upload form? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/ Share on other sites More sharing options...
TOA Posted May 18, 2012 Share Posted May 18, 2012 First and foremost, add this to the beginning of your script so you can see the errors error_reporting(E_ALL); ini_set("display_errors", 1); Then try this as a fix: $destination = "/www/zymichost.com/m/t/l/mtlproductions/htdocs/"; // move_uploaded_file accepts a filename string and destination string and if you're uploading it from a form, you'll use tmp_name if (move_uploaded_file($_FILES['thefile']['tmp_name'], $destination) === false) { // returns a bool value // your error handling here } else { // your success handling here } Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/#findComment-1346687 Share on other sites More sharing options...
xProteuSx Posted May 19, 2012 Share Posted May 19, 2012 ... I haven't gone over your code, but I know that a frequent problem is that people forget to CHMOD the directory to which they are uploading. Just check that out. I believe it should be 755. Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/#findComment-1346750 Share on other sites More sharing options...
m1k3yb0y Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks for the responses guys! I'll try them out in a few days. But for now, time to enjoy an awesome weekend! Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/#findComment-1346776 Share on other sites More sharing options...
m1k3yb0y Posted May 21, 2012 Author Share Posted May 21, 2012 Alrighty guys, now that my weekend is over, I went and tried out your suggestions. First off DevilsAdvocate, my hosting does not allow access to the php.ini file as well as that function due to security. And the adjustments you made to my code, it worked great! I saw my uploaded file at my destination! However, I attempted to see if it would upload to my uploads folder that I have in the same folder as my uploaded file. Well....no luck thanks to this: Warning: move_uploaded_file(/www/zymichost.com/m/t/l/mtlproductions/htdocs/Uploads/pho_gallery_MX5_ext1.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /www/zymichost.com/m/t/l/mtlproductions/htdocs/processfiles.php on line 4 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/www/zymichost.com/m/t/l/mtlproductions/htdocs/phpEmKcaP' to '/www/zymichost.com/m/t/l/mtlproductions/htdocs/Uploads/pho_gallery_MX5_ext1.jpg' in /www/zymichost.com/m/t/l/mtlproductions/htdocs/processfiles.php on line 4 Is there a reason for that? Proteu, how do you CHMOD the directory? Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/#findComment-1347448 Share on other sites More sharing options...
TOA Posted May 22, 2012 Share Posted May 22, 2012 Well, that doesn't go in the ini, but whatever, you have errors displayed and that was the point. To answer your question: chmod Quote Link to comment https://forums.phpfreaks.com/topic/262744-making-upload-form-file-not-uploading-help/#findComment-1347454 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.