Page 1 of 1

file upload and file permissions

Posted: Thu Feb 05, 2004 11:38 am
by andylyon87
Please please help, I have tried this code, its real basic because Ive never done it before, but if it works it will be going on my site.

Code: Select all

if($File){
print("file name: $File_name<P>\n");
print("file size: $File_size<P>\n");
if(copy($File_name, "users/$File_name"))&#123;
          print("file uploaded\n");
          &#125;else&#123;
          print("File not copied\n");
          &#125;
          unlink($File);
&#125;
  print("upload a file:");
  print("<form action=fileupload.php method=post enctype=multipart/formdata>\n");
  print("file<input type=file name="File" size=20><BR>\n");
  print("<input type=submit name=submit value=Submit!></form>\n");
The problem is it keeps coming up with permission denied errors and I was wonderin where I can change folder and file permissions, that is if there isn' any other problems

Posted: Thu Feb 05, 2004 12:47 pm
by malcolmboston
chmod 777

Posted: Thu Feb 05, 2004 1:13 pm
by McGruff
To expand a bit, you should make an upload directory with php mkdir(): that way php will be the owner of the folder and can still write to it if its set to something more secure such as 755.

You'll probably need to chmod the parent dir 777 (with your ftp program/telnet), create the new folder inside that with php, then chmod the parent back to 755 or whatever.

A dirinfo command in your ftp program can help to see what's going on. You'll notice that files/folders created with your ftp program have a different UID to those dreated with php (which often has the owner/group nobody/nobody).

Posted: Thu Feb 05, 2004 1:19 pm
by malcolmboston
thanks for explaining for me

i was feeling a lil' lazy :?