View Full Version : how to download and view any file in browser
08-02-2005, 11:32 PM
I have an application where I am storing file content in database. When I get the bytes back, I don't have the file extension and the byte content can be of any type - such as gif, jpeg, word, pdf. I am not sure what I should set on contentType to view the files.
If I don't set contentType, it attempts to open the file by the url extension which is not right. Is there a way I can find contentType from the bytes? The browsers I need to support to view the bytes content is IE and mozilla.
08-03-2005, 12:02 AM
You need to store the content type in the database too.
08-03-2005, 05:17 AM
better to use standard extension :o
08-03-2005, 09:43 PM
the problem is - when through my application, a user uploads the file, the file may not have an extension (some users just don't have files with extension). In the database, I store the filename and the bytes(blob). Because, the file extension is not provided, when I need to render the file, I am not able to set the proper contenttype. If I set the contentType=application/octet-stream, the browser opens the "File Download" dialog which has option to "Open" or 'Save". I am wondering how I can make it have the "Open With" or the Choose Program dialog?
08-03-2005, 11:14 PM
I am wondering how I can make it have the "Open With" or the Choose Program dialog?This is really up to the user agent (browser). Did you save the filename?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.