My application denies access to upload files with certain extensions for some reason. It prints out the error:
fopen(C:\wamp64\www\storage\app\public/wrdjxF3EMbtGCUyXjSEWH5zeAu822ACeKikLPaCT.): failed to open stream: Permission denied
The file types that have given out this error so far are: .msg and .txt. I have no clue what causes this problem, other file types seem to work fine.
The controller function that handles the file uploads:
if($request->hasFile('document'))
{
$files = $request->file('document');
foreach($files as $file){
if($file){
$name = $file->getClientOriginalName();
$size = $file->getClientSize();
$size = number_format($size / 1048576,2);
$path = $file->store('public');
Document::create([
'report_id' => $id,
'report_type' => "App\VisitingReport",
'file_path' => $path,
'file_name' => $name,
'file_size' => $size.' MB'
]);
}
}
}
Any help would be appreciated, thanks.
I'm running this on a Windows computer using WAMP.
I am convinced that it has something to do with the permissions indeed. I'm already a step further, the file gets uploaded but this time without the extension.