File Uploaded – preview option for uploaded files

QuestionsFile Uploaded – preview option for uploaded files
Simon Tavner asked 4 years ago

Hi,

Some users have asked if it would be possible to preview an uploaded file without having to download it first. All uploaded files are PDF, I would assume to do this a jpg sidecar image would have to be uploaded also?

This might be testing my coding skills a little too much, can you please tell me if this would be possible before I spend too much time on it.

Thanks,

2 Answers
Abu Ghufran Staff answered 4 years ago

Hi,

You can create a php script (e.g. preview.php) as mentioned here and use it in image src on grid.

$col[“template”] = “<img src=’preview.php?pdf={pdf_url}’ />”;

Assuming pdf_url is column having pdf url link, you can pass pdf link to preview.php and generate thumbnail from php file and used as source of img tag.

Another online solution is to use google drive online pdf viewer.
https://drive.google.com/viewerng/viewer?embedded=true&url=http://domain.com/test.pdf

You can put above link in a column on grid with a label of preview.
$col[“template”] = “<a href=’https://drive.google.com/viewerng/viewer?embedded=true&url={pdf_url}‘>Preview</a>”;

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Simon answered 4 years ago

Thanks Abu, I’ll try the script option to keep it in-house as far as possible.

Your Answer

20 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?