File Upload in Laravel

File Upload in Laravel


file upload in laravel

This article is about the file upload in laravel

It can be done by using two files one in controller and another in view does the job.

First have to create a view file where user can upload files under(resources/views/upload.blade.php)

Create a controller called uploads under app/Http/Controllers/UploadController.php which will validate the file uploaded and process it.

Now finally dont forget to define your routes to make it work.

READ  Run Laravel on Google Cloud Platform

Make Sure you create a directory  public/uploads with 0777 permissions where script storing files.

Useful functions to remember:

  1. The getClientOriginalname() used to get the actual name of the file when it is uploaded.
  2. getFilename() used to get the temporary name of the file given to our file on its temporary location.
  3. getRealPath() used to get the current location of the uploaded file.
  4. getClientSize() used to get the size of the uploaded file in bytes.
  5. getClientExtension() used to get the extension of the uploaded file.
  6. move() used to move the uploaded file to target location.First parameter is target or destination ,second parameter is the name of the file.

Comments are closed.