-1

I am learning Laravel. I want to show image(give download option)/pdf(show name of pdf file and give download and view(view on browser, in new tab) option) depending on extension on my view.

I have file_docs table. In that table I have column buyers_aadhar_file. In that column I am storing files like image OR pdf. I am customising name of file while storing like "buyersid_B_aadhar_nameoffile.ext" e.g 2_B_aadhar_Aadhaar-Card-New-Rules-Update-644x362.jpg or 3_B_aadhar_Aadhaar-Data-Update-Form-03.pdf

Now I want to display that files depending on type of file.

If file is image then show image also give download option for image. And if file is pdf then show name of pdf file, give download and view pdf file option for that file.

How do I check on my view, whether that file is image or pdf and how to implement relative download and view option for that file?

ganesh
  • 416
  • 1
  • 11
  • 32

1 Answers1

0

you could use path_info, a php function in the laravel view file to fetch the file extension and stuff like that and you could look into this link for image showing and pdf showing in your view file

HexaCrop
  • 3,863
  • 2
  • 23
  • 50