I would like to upload a .gpx file to storage using Laravel. I don't want to do anything with it, just upload it. Currently trying to upload only to my local machine.
Whenever I try to do it, I get the following error: " failed to open stream: Permission denied".
I am able to upload other files, including .png and .csv files. I am able to upload larger files than the .gpx file.
When I check the mimetype it syas "application/octet-stream".
I am unsure if this is the reason it won't upload.
Code in Form:
<form action="/gpxfiles" enctype="multipart/form-data" method="POST">
{{ csrf_field() }}
<table class="table table-striped table-hover tablesorter" id="table">
<thead class="thead-dark">
<th>Filename</th>
</thead>
<tbody>
<tr>
<td>
File:
<input type="file" name="gpxfile" id='gpxfile' />
</td>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" class="btn btn-primary btn-lg">
Code in Controller
if(request('gpxfile'))
{
$file = request('gpxfile');
$mime = $file->getClientMimeType();
$path = Storage::putFile('files\gpxfiles', $request->file('gpxfile')); //<-Fails Here
}
Any help would be much appreciated.
I eventually found a format that works, though I don't know why.
This code works:
$path = Storage::putFileAs('files\gpxfiles', $request->file('gpxfile'),'test.gpx');
While this code says "Permission Denied"
$path = Storage::putFile('files\gpxfiles', $request->file('gpxfile'));
And this code says "Permission Denied"
$path = Storage::put('test.gpx', $request->file('gpxfile'));
But only for gpx files. All lines of code works for images.
Hopefully this helps anyone who stumbles upon the same problem I had.