svgmx5 Posted August 8, 2011 Share Posted August 8, 2011 I'm having a problem uploading files with using move_uploaded_file() function. I'm pretty sure i know that is related the folder permissions, however i've tried using chmod() to change the permissions of the folder so i can upload it but i get the following error: Warning: chmod() [function.chmod]: Permission denied in D:\Hosting\8163784\html\demo\dashboard\myadd\place_bid.php on line 250 and this is the script that i'm using: chmod("../files/cp_ads/", 0777); The path "files/cp_ads/" is one level up from the file that the script above is at. Basically i want to change it to 0777 so it can uplaod the file and then i change the permissions again to the default. I've tried changing the permissions by going through the ftp server to 777 and i can upload the file with no problems..but when i set it to 0664 and i try to change the permission using the script above it won't let me .. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/244271-error-when-changing-folder-permission-using-chmod/ Share on other sites More sharing options...
requinix Posted August 8, 2011 Share Posted August 8, 2011 Only the owner of the folder (and root) can change permissions. Since PHP is not running as the same user you FTP in as, PHP cannot change the permissions. Quote Link to comment https://forums.phpfreaks.com/topic/244271-error-when-changing-folder-permission-using-chmod/#findComment-1254598 Share on other sites More sharing options...
svgmx5 Posted August 8, 2011 Author Share Posted August 8, 2011 in that case, how can i allow people to upload files to the server with out changing the permissions through the ftp? basically users are allowed to upload files to the server and the only way i see so far is to permanently change the permissions to 777 on the server, which i don't feel comfortable doing since it will be open to anyone and i just want to open it to the users who are signed up. I just want to be able to open the folder, upload the file and then close it Also if it helps..the server is a shared server with godaddy and its a windows server Quote Link to comment https://forums.phpfreaks.com/topic/244271-error-when-changing-folder-permission-using-chmod/#findComment-1254600 Share on other sites More sharing options...
requinix Posted August 8, 2011 Share Posted August 8, 2011 Since you don't have control over the webserver/PHP setup, all the solutions have flaws. IMO the best you can do is let PHP create that folder and leave it as the default 0755. Every instance of PHP could modify the contents of the directory, but somebody would have to use PHP to access the contents rather than do so directly. 1. chmod 0777 files/ 2. Make a quick PHP script to create files/cp_ads 3. chmod 0755 files/ back Quote Link to comment https://forums.phpfreaks.com/topic/244271-error-when-changing-folder-permission-using-chmod/#findComment-1254616 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.