lara33495's avatar

How to display file which had already upload laravel 5.2?

I upload file in to my database and moved that file as same name in documents folder in a root path like below :)

public function store(PslCall $call,Request $request)
    {
        $this->validate($request, $this->rules);
        $uploadDestinationPath = base_path() . '/documents/';
        $current_id = Document::where('call_id',$call->id)->count()+1;
        if ($request->hasFile('file'))
        {
            $file =$request->file;
            $fileName = $file->getClientOriginalName();
            $file->move($uploadDestinationPath, $call->id.'_'.$current_id.'_'.$fileName);
        }
        $input = $request->all();
        $input['file'] = $call->id.'_'.$current_id.'_'.$fileName;
        $input['call_id'] = $call->id;
        Auth::user()->documents()->create($input);
        return Redirect::route('calls.documents.index',$call->id)->with('message','You have successfully submitted');
    }

its works perfect now im display in my index page all the files like below :)

<td>{{strtoupper($document->title)}}</td>
<td><a href="{{ url('documents/'.$document->file) }}" target="_blank">{{$document->file}}</a></td>

now my route file i have route to display my file like this :

Route::get('documents/{file}',function() {
  return 'hi';
});

here im getting hi output when i click ~~~{{$document->file}}~~~ this path

but i want know how to display file which i upload same file name ?

http://stackoverflow.com/questions/39271278/how-to-display-file-which-had-already-upload-laravel-5-2

0 likes
2 replies
lara33495's avatar

omg.............................................. no one answer this

icon's avatar

Hi Hamelraj! How did you solved this topic? Thanks!

Please or to participate in this conversation.