1

I'm new to the laravel 5.4.but I have to create a file uploading system. If it is a PDF or other documents:

  1. Upload them seperatly
  2. delete or download it them seperatly.

As I'm new to laravel I started with this. Can anyone help me to get it functioning properly?

Here is my UploadController

class UploadController extends Controller
{
    public function index(){

        return view('upload.index');
    }

    public function multiple_upload(){

        $files = Input::file('images');
        $extention = $file ->getClientOriginalExtention();
        $entry = new Uploads();
        $entry -> mime = $files ->getClientMimeType();
        $entry -> filename = $files ->getFilename().'.'.$extention;
        $entry -> save();
    }
}

Here Is my Routes

Route::get('upload', 'UploadController@index');
Route::post('upload/uploadFiles', 'UserController@multiple_upload');

Here Is my View index.blade.php

<form action="upload" id="upload" enctype="multipart/form-data" >
    <label>Uplod your Attachments</label>
    <input type="file" name="file[]" multiple="" >
    <input type="submit" >
</form>

Here Is My Migration

 Schema::create('upload_3a12', function (Blueprint $table) {
        $table->increments('id');
        $table->string('filename'); 
        $table->string('mime');
        $table->timestamps();
    });

Hope You will help me lot. Thank you.

1
  • What's the exact problem you face in your code ? Be more specific Commented Mar 7, 2017 at 19:14

1 Answer 1

1

You are looking at a field called "image" and you are naming your input field "files" and allowing multiple uploads, so you have to loop over files[], and also I will recommend adding some validation rules to your code.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much for the advise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.