Hi,
I'm using mass-assignment to insert a load of records into the database, how do I handle a file upload with the procedure?
Do I grab the file upload from the POST array, upload it to my chosen path and assign the location value back to the array that's passed to the mass-assignment, or is there a better way?
Thanks
Pretty much how you described, but don't use POST array, use Request's methods.
$uploadedFile = $request->file('myfile');
$uploadedFile->move('directory/for/files/', 'filename.ext');
$uploadedFile
is an object of Symfony\Component\HttpFoundation\File\UploadedFile
class, it has some useful function for getting file name, extension, type.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community