rklockner Posted June 25, 2014 Share Posted June 25, 2014 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. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted June 25, 2014 Share Posted June 25, 2014 (edited) If most of the files are images, try getimagesize(). You can also combine this with the finfo_file() and extension checks (for the files which have one). Edited June 25, 2014 by Jacques1 Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 25, 2014 Share Posted June 25, 2014 (edited) 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 June 25, 2014 by Psycho Quote Link to comment Share on other sites More sharing options...
rklockner Posted June 26, 2014 Author Share Posted June 26, 2014 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! 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.