samedi 4 août 2018

Change file permission before downloading in laravel

What I have:

A file with the permission of 0444.


What I want:

Whenever a guest user downloads that file, it should retain the file permission, i.e., 0444 only.


The code that I have tried so far:

$file = public_path('/List-of-Forms.xls');


$suc = chmod($file, 0444);


// dd($suc, exec('ls -la ' . $file));

// $suc returns true
// exec returns -r--r--r-- 1 user user 112128 Aug  4 11:07 /path/to/file.php

return response()->download($file);


The thing is that, whenever the file is downloaded, the permission is changed to 0664. I want to change it back to 0444.


Cut short:

How to change the permission of file before starting the downloading so that it retains 0444 or is/are there any headers that I need to add/edit?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire