asadbinamer's avatar

Upload file in laravel 5.4

I am uploading the file and it is showing the file also but not storing the file in folder here is my code......Please help me

routes.php

Route::get('/view' , 'UploadsController@show'); Route::post('/upload' , 'UploadsController@upload');

upload.blade.php

@extends('blog.master') @section('content')

{{csrf_field()}} @endsection

uploadscontroller.php

0 likes
5 replies
asadbinamer's avatar

upload.blade.php

class UploadsController extends Controller { public function show (){ return view ('blog.upload'); }

public function upload(){
    if(Input::hasFile('file')){
        echo 'Uploaded';
        $file=Input::file('file');
        $file->move('uploads' , $file->getClientOriginalName());
        echo '<img src="uploads/' . $file->getClientOriginalName().'"/>';
        
        
    }

    else {

        echo 'Not Uploaded';
    }
}

}

silverxjohn's avatar

Make sure you have a folder named uploads in your project root directory.

e.g MyLaravelProject\uploads

also you have to have a permission to write in the said directory.

vipin93's avatar

here u should give full path

 "public_path('/uploade) or storage_path('upload)"

Please or to participate in this conversation.