Reputation: 5107
I have a fairly simple setup here where I'm taking file attachments that are dragged and dropped on the front end and then saving the filename to the database and saving the files to aws. Now, the filename dumps properly and saves in the database just fine, but when calling the controller to save the files in AWS I have issues.
I currently get the error "Call to member function getClientOriginalExtension() on string" but the string is the correct file name at least.
What am I doing wrong and how can I get this to properly save to my AWS bucket?
attach.vue
let data = {
attachment:file.upload.filename
};
axios.post('/attachment/save', data)
.then((response) => {
console.log(response.data);
})
controller.php
public function save(Request $request)
{
$filename = (string) Str::uuid();
$filename .= '.' . $request->attachment->getClientOriginalExtension();
$path = $request->attachment->storeAs('attachments', $filename, 's3');
}
Upvotes: 0
Views: 478
Reputation: 1807
I would guess that this is probably caused because you haven't actually pulled the file.
getClientOriginalExtension()
used when you have file on your request like this:
$name = Input::file('photo')->getClientOriginalName();
Upvotes: 1