Unstinted's avatar

Saving Image upload and File to a Folder in my laravel

How can i save images and file uploaded on job application form to folders in my lavavel mvc apps.

Please i need your views.

0 likes
3 replies
BENderIsGr8te's avatar

The form needs to have an enctype of multipart/form-data. You can either add the attribute directly to your form, or you can add a 'files' => true if you are using the FORM helper.

Once you have your form setup correctly, the Request item will have access to it. Assuming you name your form upload file "profile_image"...you could do the following...

public function processForm(Request $request) 
{
    if( $request->hasFile('profile_image') ) {
        $file = $request->file('profile_image');
        // Now you have your file in a variable that you can do things with
    }
}

If you want to see how to move to the file and do other things with it just take a look at this... http://laravel.com/docs/5.0/requests#files

MarkMatute's avatar

$file->move($destinationPath, $filename); works like move_uploadedfile i guess :))) Ive been working on that for 2 dayss :D You may also check out the package 'intervention/image '

anonymouse703's avatar

@MarkMatute Can I ask , what will be the configuration of the path if you want to save your upload file in a folder located in desktop?

Please or to participate in this conversation.