1

I'd transfer my site to linux hosting, Its has an issue on uploading image to the system's auto create folder which permission is chmod 0777, I found that its always make the uploading failed because of owner/group is in www-data, how could it change owner/group to 'root' in order to upload the image into the folder?

$media_path = "../upload/".$nextid;

if(file_exists($media_path)){
//do nuthing

}else{

mkdir($media_path, 0777);
chmod($media_path, 0777);
chown($media_path, "root");
chgrp($media_path, "root");

}

Please advice. Thanks.

conmen
  • 2,377
  • 18
  • 68
  • 98

1 Answers1

0

You cannot use chown unless you are root. But creating the folders with 0777 is sufficient to allow anyone to write to them.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • unfortunately I couldn't write file into the folder unless i create folder thought FTP by self, the folder ownership would be in 'root' – conmen May 15 '12 at 10:24