Jump to content

handling files and mime-type etc..


Chris Val Kef

Recommended Posts

i have files stored in a folder and i want user can download them. Mime-type and file-size have to be stored in database when i upload the file or it doesn't matter? are there any simple code examples with files for download or something? I want to return an icon for different type of files (ie the icon of Acrobat for .pdf)

it's the first time i'm handling files so any help would be very very useful!

Link to comment
Share on other sites

Usually what I do is when I upload the file I will strip it's extension to see what type of file it is. Yes its not entirely accurate but since I am the only using the script I know a .PDF will be a PDF ;)

When displaying the files I would use a [code=php:0]switch()[/code] statement to determine what icon I would show for the file type.

Database wise I store as much as I can about the file.  Filesize, Filetype, Filename, uploaded time etc.  I learnt that you have to make sure your filesize is corrent when you have a download script get the file and offer it to the client downloading it. Setting up the file's header prior to downloading will corrupt the file.
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.