Im generating a file to present to the user for download, but the server isnt letting me open it, because it needs to have permissions of 777 before it can do so.
Here is my code
$fh = fopen("$name", 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize("$name").";");
header("Content-Disposition: attachment; filename=$name");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
readfile($name);
any way to set the permissions of this before before i open it, or how would i go about doing this? The file has not been created yet, so it might be kind of a endless loop. Should i make the file, then open it, or what?