jgingras Posted August 14, 2005 Share Posted August 14, 2005 Hi Everyone, I just had a question on file upload, im trying to upload a file and when I check the is_uploaded_file(), it says that it worked correctly, but I dont know how to set the path to move_uploaded_file. I created a folder in my public_html directory, but dont really know how to proceed from here? Let me know if anyone had a suggestion. Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 15, 2005 Share Posted August 15, 2005 The path you'd need to use for a subfolder in your public_html directory would be: >/home/cpanelName/public_html/my_sub_folder ...where 'cpanelName' is your CPanel username, and 'my_sub_folder' is the name of the subfolder you created. I don't know if that totally answers your question, but I hope it helps! Quote Link to comment Share on other sites More sharing options...
jgingras Posted August 18, 2005 Author Share Posted August 18, 2005 Dave, I haven't gotten a chance to give it a shot yet, but it sounds like it will work great! Thanks, Ill keep you updated when I give it a shot tomorrow. -Jacques Quote Link to comment Share on other sites More sharing options...
jgingras Posted August 18, 2005 Author Share Posted August 18, 2005 Ok, The error that im getting is >Warning: move_uploaded_file(/home/cpanelname/public_html/foldername/filename): failed to open stream: Permission denied in /home/cpanelname/public_html/file.php on line 39 Warning: move_uploaded_file(): Unable to move '/tmp/tmp_filename' to '/home/cpanelname/public_html/ProjectDocs/filename' in /home/cpanelname/public_html/file.php on line 39 Do I need to do something in cPanel to allow my user to upload files? Im new to php and things like that. Thanks for your help., -Jacques Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted August 18, 2005 Share Posted August 18, 2005 Is ProjectDocs actually that name? The servers are case sensitive. And is that folder permissions set to 777? Quote Link to comment Share on other sites More sharing options...
abinidi Posted August 18, 2005 Share Posted August 18, 2005 (edited) Ok,The error that im getting is >Warning: move_uploaded_file(/home/cpanelname/public_html/foldername/filename): failed to open stream: Permission denied in /home/cpanelname/public_html/file.php on line 39 Warning: move_uploaded_file(): Unable to move '/tmp/tmp_filename' to '/home/cpanelname/public_html/ProjectDocs/filename' in /home/cpanelname/public_html/file.php on line 39 Do I need to do something in cPanel to allow my user to upload files? Im new to php and things like that. Thanks for your help., -Jacques <{POST_SNAPBACK}> Hi Jacques, Is it safe to assume that when your error message says "cpanelname" that you actually are using your cPanel login name? For example, if your cPanel login name is abcxyz and your subfolder is named 'blog' then you should really using the following path: /home/abcxyz/public_html/blog I'm just checking, because sometimes users forget that they have to customize the cPanel name. You probably didn't have this problem, but it never hurts to check... Edited August 18, 2005 by abinidi Quote Link to comment Share on other sites More sharing options...
jgingras Posted August 19, 2005 Author Share Posted August 19, 2005 Is ProjectDocs actually that name? The servers are case sensitive. And is that folder permissions set to 777? <{POST_SNAPBACK}> I did use the correct case for the folder, how do I set the permission to 777? Also, what would happen if I put a path of a folder that hasn't been created? Would it automatically create it, or would I have to create the folder ahead of time? And, if this is the case, is there a way to create the folder and set its permission using php? Thanks, Jacques. P.S. and yes. i did change cpanelname to my username.. thanks! Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted August 19, 2005 Share Posted August 19, 2005 Folders are not created on the fly you have to create them. You can change the permissions to 777 using an FTP program or through cPanel. Not sure if you can create and set permissions using PHP. Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 19, 2005 Share Posted August 19, 2005 Not sure if you can create [folders] and set permissions using PHP. <{POST_SNAPBACK}> You can use mkdir('/pathname'); to create the directory, and chmod('/pathname', 0777); to set its permissions. The directory will be owned by the user 'nobody' instead of you though, since PHP scripts run as that user. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted August 19, 2005 Share Posted August 19, 2005 I really need to start getting deeper into PHP. I know just about enough to be dangerous. Quote Link to comment Share on other sites More sharing options...
abinidi Posted August 19, 2005 Share Posted August 19, 2005 You can use mkdir('/pathname'); to create the directory, and chmod('/pathname', 0777); to set its permissions. The directory will be owned by the user 'nobody' instead of you though, since PHP scripts run as that user. <{POST_SNAPBACK}> David, what are the implications of having the directory be owned by "nobody"? Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 19, 2005 Share Posted August 19, 2005 For a directory owned by 'nobody' where the permissions not set to 0777 (such as 0755), you would not be able to create or delete files and subdirectories in that directory from your FTP program or CPanel. If a file is owned by 'nobody' and its permissions are not set to 0777 (such as 0644), you would not be able to edit the file except via a PHP script. You would also not be able to change the permissions on a file or directory owned by 'nobody' using your FTP program or CPanel, as you have to own the file or directory in order to change its permissions. Again, you'd have to use a PHP script to change permissions on a file or directory owned by 'nobody', or submit a ticket to the Help Desk (who can change the owner and permissions on any file as the 'root' superuser). Quote Link to comment Share on other sites More sharing options...
jgingras Posted August 24, 2005 Author Share Posted August 24, 2005 Thanks everyone for your replies. I will give that a shot as soon as I get the chance and let you know how it works out! Thanks, -Jacques Quote Link to comment 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.