vendredi 24 novembre 2017

Laravel | Multiple file upload not working

I am trying to save multiple photos at a time and I have verified that the request has an array of files so that is working correctly. dumping $request->collegeBrochures shows: enter image description here

However I have some logic error while saving those files from request. this code is not working

   if ($request->hasFile('collegeBrochures')) {
        $files = Input::file('collegePhoto');
        $names = [];
        foreach ($files as $file) {
            $name = 'brochure-'.$college->id.'-'.$file->getClientOriginalName().'.'.$file->getClientOriginalExtension();
            array_push($names, $name);
            $file->move(storage_path().'/Images/colleges/', $name);
        }
        $college->collegeBrochuresPath = json_encode($names);
    }

What is going wrong here?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jkvqAZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire