By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Problem in file permission

vivekgs2007
P: 60
Hi to all,
I created a php file, Where the files are uploaded in to a folder. When i am assessing to that file, it is showing 404 forbidden error, I got the error,It is in file permission of the folder, so i changed the permission to 777, I want to change the permission dynamically, when ever i upload the new file, it must change to 777.
i used this code
Expand|Select|Wrap|Line Numbers
  1.  
  2.  $photo = $_FILES['photo']['name'];
  3.   $photo = chmod($photo,777)     move_uploaded_file($_FILES["photo"]["tmp_name"],"project_photo/".$_FILES["photo"]["name"]);
  4.  
but it is not displaying the photo.
Please help me in this.
Mar 27 '10 #1

✓ answered by Atli

Hey.

I see three problems there:
  1. You are calling the chmod on the wrong path. You need to call it on the exact path where your file is saved, not just on the file's name.
  2. The file must be created before you try to change it's permission.
  3. The chmod function returns a boolean, not a file path. You should use it to check whether the file was successful or not. (See the documentation.)
Fix these first and then see what happens.

Share this Question
Share on Google+
2 Replies


Atli
Expert 5K+
P: 5,058
Hey.

I see three problems there:
  1. You are calling the chmod on the wrong path. You need to call it on the exact path where your file is saved, not just on the file's name.
  2. The file must be created before you try to change it's permission.
  3. The chmod function returns a boolean, not a file path. You should use it to check whether the file was successful or not. (See the documentation.)
Fix these first and then see what happens.
Mar 27 '10 #2

vivekgs2007
P: 60
Hi Sir,
Thank You very Much...I am very Greatfull to you...U have saved me...I got the answer...
Check this site http://www.eitech.in/prj_project.php?value=1
Mar 29 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.