0

I want to update the file in laravel 5.6. But the file is not showing in edit.blade.php. When i click update button the file goes null..

editfile.blade.php

<div class="control-group">
          <label class="control-label">Publication File</label>
          <div class="controls">
            <input type="file" name="publication_file" id="publication_file" value=" {{ $publicationDetails->publication_file }}"> <span> {{ $publicationDetails->publication_file }} </span>
          </div>
        </div> 

Update function in controller

 if($request->isMethod('post')){
        $data = $request->all();

        Publication::where(['publication_id'=>$publication_id])->update(['publication_title' => $data['publication_title'],'publication_type'=>$data['publication_type'],'publication_file'=>$data['publication_file']]);
       return redirect('/admin/view-publication')->with('flash_message_success','Publication Updated Successfully..');
    }
    $publicationDetails = Publication::where(['publication_id'=>$publication_id])->first();
    return view('admin.publication.edit_publication')->with(compact('publicationDetails'));

1 Answers1

0

There is no built-in way for Laravel to edit PDFs. You can of course use external libs, such as FPDF with the FPDI extension to modify PDFs or tcpdf to write in predefined file, or u can create pdf based on html file - the result is a new PDF file. There is also a paid lib PDFlib that is capable of editing PDFs.

  • You have to store file temporary at server and then edit that file using external library.. you can replace existing file or [delete](https://laravel.com/docs/5.6/filesystem#deleting-files) existing file ... and save new edited copy of file. – Rahamtulla Inamdar Jul 16 '18 at 11:38
  • 2
    Dear, copying existing answers isn't a great way to gain rep (https://stackoverflow.com/a/37210137/5879295) – Andriy Klitsuk Nov 06 '18 at 09:46