Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muuucho's avatar
Level 11

Storing images and pdfs for clients on a remote server

I need som advise. In my project, users can upload invoices in various formats, like jpg and pdf. Each uploaded file is stored on a remote server using SFTP, and when a file (image or pdf) is uploaded, also a jpg thumbnail is created and stored.

I then display the thumbnails to the user, and the user can click any thumbnail and the high resolution original gets displayed.

Since an invoice file can be an image or a pdf, I use the tag in the view to display an invoice. This tag displays images and when it comes to multi page pdf it is displayed scrollable, which is important. The embed tag works on larger screens, however it doesn't work on mobiles.

An alternative is to let Google handle it, but then I guess I need to expose the path, so that is not an option for me.

So, how can I display an (high resolution) image or even a scrollable multi page pdf to users on various devices like pcs, tablets, mobiles?

0 likes
1 reply
LaryAI's avatar
Level 58

To display high-resolution images and scrollable multi-page PDFs on various devices, you can consider the following approach:

  1. Use a JavaScript PDF Viewer Library: Libraries like PDF.js can render PDFs directly in the browser, providing a consistent experience across devices. PDF.js is an open-source project by Mozilla that allows you to embed PDFs in your web application without relying on third-party services.

  2. Responsive Design for Images: For images, ensure that your HTML and CSS are responsive so that images scale appropriately on different screen sizes.

  3. Conditional Rendering: Use JavaScript to detect the type of file and render it accordingly. For images, you can use an <img> tag, and for PDFs, you can use PDF.js.

Here's a basic example of how you might implement this:

Key Points:

  • PDF.js: This script uses PDF.js to render PDFs. It loads the PDF document and renders each page onto a canvas element.
  • Responsive Images: The image is set to 100% width to ensure it scales with the screen size.
  • Device Compatibility: This approach should work across different devices, including mobiles, as it uses standard web technologies.

By using a library like PDF.js, you avoid exposing file paths to third-party services and maintain control over how documents are displayed.

Please or to participate in this conversation.