Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel file upload

<?php

   

namespace AppHttpControllers;

  

use IlluminateHttpRequest;

  

class FileUploadController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return IlluminateHttpResponse

     */

    public function fileUpload()

    {

        return view('fileUpload');

    }

  

    /**

     * Display a listing of the resource.

     *

     * @return IlluminateHttpResponse

     */

    public function fileUploadPost(Request $request)

    {

        $request->validate([

            'file' => 'required|mimes:pdf,xlx,csv|max:2048',

        ]);

  

        $fileName = time().'.'.$request->file->extension();  

   

        $request->file->move(public_path('uploads'), $fileName);

   

        return back()

            ->with('success','You have successfully upload file.')

            ->with('file',$fileName);

   

    }

}
Source by www.itsolutionstuff.com #
 
PREVIOUS NEXT
Tagged: #laravel #file #upload
ADD COMMENT
Topic
Name
7+7 =