Multiple file upload

Posted 1 month ago by lawkunchi

How do I store file paths of multiple file upload input. Below is my controller so far

public function postDeal(Request $request) 
        $this->validate($request, [

            'property_address' => 'string|required|max:100',
            'sell_price' => 'string|required|max:100',
            'docs' => 'required|max:10000',

        $files  = $request->file('docs');
        $paths = [];

        foreach( $files as $file) {
            $extension = $file->getClientOriginalExtension();
            $filename = 'sup-doc-' . time() . '.' . $extension;
            $paths[] = $file->storeAs('Deals', $filename);

        $deal = new Deal([
            'property_address' => $request->input('property_address'),
            'sell_price' => $request->input('sell_price'),
            'docs' => $paths,

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.