Hi, i have successfully stored a link to docx and pdf files into mysql db. I'm trying to retrieve it from db and display it similar to pictures. Now when the user click on it, it should open the file and display it.

If any one have a code sinppet that can do that or something similar, pls help. Thank you...

Recommended Answers

All 5 Replies

Would it work if you would just retrieve the links to the files from you DB, then check what file type it is, and then display an icon for that file type instead of a preview of the file? For example for a .doc file you display a Microsoft Word icon with the file name next to it, and then when the user clicks it he is prompted with a "download file" window.

Alternatively, have one standard.. PDF (which is compatible through many operating systems) thus providing that all documents can be open in the web browser.

Member Avatar for diafol

Most files like Word documents will get downloaded when you click their links. There are some online viewers though, but they aren't always accurate in what they display, e.g. Dropbox's viewer - there are certain elements that don't quite look like they should. So, IMO, best to leave files of that type as 'downloads'.

minitauros and diafol, do u have a sample code? Am having trouble with what i have.
Member Avatar for diafol

Sample code for what? I suggest not using viewers, just provide links to those files and they'll download.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.