简体   繁体   中英

open file and download does not work in ubuntu

i complete my code on windows xampp to download text(or other file) file and its work good but when i upload the code on ubuntu server its does not work can you help me plz

$file = "$username.rsc";
$txt = fopen($file, "w") or die("Unable to open file!");
fwrite($txt,
"{
anything
}

");
fclose($txt);

header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
  ob_clean();
    flush();
header('Content-Length: ' . filesize($file));
header("Content-Type: text/plain");
readfile($file);

the response on ubuntu is Unable to open file!

This sounds like a permissions issue. Make sure that your Apache user and group has access to the file and directory that you are trying to modify.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM