Jump to content

PHP and MySQL Display Files


SirTrunks

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.