I am using PHP to retrieve some Base64 data, decode it and write it to some file, my code works fine. However, the dog owner is apache and also the permissions are extremely low, so even when I FTP in to the area where it's submitted, i am unable to download the file. However will i alter the permission and owner and so i convey more treatments for the file? Here's my code

$path = "uploads/";
$filename = time().".png";
$full_path = $path.$filename;

$image_encoded = $_POST['image'];
$image_decoded = base64_decode($image_encoded);

$handle = fopen($full_path, 'x+');
fwrite($handle, $image_decoded);

you might like to use chmod to alter file permissions.

Possibly you aren't titled to download it... You might change it's permissions to 755 or something like that...

chmod($full_path, 0755);
$handle = fopen($full_path, 'x+');


You need to have the ability to change it's permissions since the file was produced by php(the dog owner)...

The superuser and also the files' owner can alter the dog owner with:

The files' permissions could be transformed using:

Plese note you should utilize octal notation for that files' permissions, string notation as with Unix will not work! To grant the files' owner every permission, and also to permit the other customers to have the ability to read (download) it, the permisison in octal notation is: chown ( string $filename , mixed $user )

See Wikipedia for more information about the octal notation of file permissions.