Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to download and view any file in browser

    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.

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You need to store the content type in the database too.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #3
    Banned
    Join Date
    Jun 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    better to use standard extension

  • #4
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #5
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by user11
    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?
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •