SirTrunks Posted July 15, 2013 Share Posted July 15, 2013 Hey guys, Hope someone can help me out. I am trying to display files that are stored in a MySQL database into a php file. I want to display the file as a hyperlink so i could click on it and it will open up. the files in the DB is pdf, docx, and xlsx files. Eventually i want to display the image icon of the file, but want to get this to work first. This might sound confusing, but shoot me a comment and I could explain it more. thanks in advance. Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 15, 2013 Share Posted July 15, 2013 Are you only storing the name and location of the file in the DB? The files themselves should be stored in folders like any normal file. Displaying a pdf in the browser is fairly easy but the others are much more complicated. Do you just need a link to be able to download the file to the clients computer? Please explain more of what you need and how things are setup. Quote Link to comment Share on other sites More sharing options...
SirTrunks Posted July 15, 2013 Author Share Posted July 15, 2013 the db has the file name and the location of the files and the files are being saved into a folder within the server. I would like to display the file name which i have done by stating a select and while loop within my php code, but i'm having issues in how to display the content of the file. I love to have the user click on the file name and be able to download it locally into there machine to view. by the way, i find it strange that mysql store file into *.dat file even though the file is pdf or docx format; is that going to be an issue. thank you for help. Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 15, 2013 Share Posted July 15, 2013 by the way, i find it strange that mysql store file into *.dat file even though the file is pdf or docx format; is that going to be an issue. The DB can't decide what file extension to store the data in, you do that through your script or manually. Maybe you should post a screenshot of your db data in question. There are plenty of download scripts online but I can't seem to find a really good one at this moment. I may do a tutorial on this soon, so I'll post it back here when I do. Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 16, 2013 Share Posted July 16, 2013 Here is the php force file download tutorial. http://amecms.com/article/PHP-Force-File-Download-With-File-Whitelist Quote Link to comment Share on other sites More sharing options...
SirTrunks Posted July 16, 2013 Author Share Posted July 16, 2013 here is a screen shot [link below] of the data within the table. it would be awesome if all the attachments in the database were pdf but no there is a mix of documents. http://goo.gl/QP4mj Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.