Jump to content

Detecting Mime Types


rklockner

Recommended Posts

I have a scenario where users are downloading files from a legacy system and uploading the files into a new system that I am supporting.  Many of the files do not have an extension (most are tiffs).

 

The issue we have is that the new system doesn't know how to open these files (we have them open in a preview window in the new system).  I have tried numerous solutions, including finfo_file() and the depreciated mime_content_type() funcitons), but all they seem to return is "application/octet-stream".

 

Thanks.

Link to comment
Share on other sites

What does " . . . the new system doesn't know how to open these files . . . " mean? How are you trying to "open" them and for what purpose? Are you trying to open them through PHP in some manner? Or, are you trying to open them outside of a PHP application?

 

If the problem is trying to open these outside of any PHP logic, then you could modify the upload process to use finfo_file() as suggested above and dynamically add an appropriate extension to the file name when saved. That way Windows (assuming) would know the appropriate application to use to open the file. If the problem is with some process in PHP that "opens" the file, then some more details around what you are doing with the file may be helpful

Edited by Psycho
Link to comment
Share on other sites

Here goes my sheepish response...

 

The tiff file I was using for testing had something wrong with it.  Once I figured this out, getimagesize() worked which made me decide to give finfo a try again, and it also worked, so I switched it back to that.

 

Thanks for the hints!

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.