SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Opening files via header

  1. #1
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Opening files via header

    I have files stored in mysql (only way to do it for the current situation) and whenever i retrieve them, i retrieve them by passing the correct headers to the browser. This works perfectly on a PC. However, on a macintosh, it always opens it as the php file doing all the work, instead of the file name.

    Is there a way to open files by passing headers via browser on a MAC? I have to store the files in MySQL.

  2. #2
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know SOMEONE has a mac

  3. #3
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What browser are you experiencing this with? What headers are you sending?
    TuitionFree — a free library for the self-taught
    Anode Says...Blogging For Your Pleasure

  4. #4
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both IE and safari. I'll post the headers when I get into work in the morning.

  5. #5
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    header("Content-disposition: filename=$filename");
    header("Content-Type: $mimetype");
    header("Content-Length: " . strlen($filedata));

  6. #6
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try Content-disposition: attachment; filename=$filename
    TuitionFree — a free library for the self-taught
    Anode Says...Blogging For Your Pleasure

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Singapore
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What type of files are they? Do you want them inline or as a download?

  8. #8
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Didnt work. what its doing is its saying its an invalid mime-type. I uploaded a .zip via a PC, and the mime-type is different then when a MAC uploads it.

    Now if i just rename the file to the right name and extension and then press for it to save, the file will work. But it should give the right name and extension without me having to rename it.

  9. #9
    Bah, I'll just hack it DoobyWho's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by biggulp
    What type of files are they? Do you want them inline or as a download?
    All sorts of files. And they need to work on both PC and MAC (if its not a platform specific file, like .exe for example) whether its uploaded from a PC or MAC.

    If the file can be opened in the browser, I want it to open. But if it cant be opened, i want it to prompt for a download.

Bookmarks

Posting Permissions

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