#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    4
    Rep Power
    0
    Hi,

    This may be a little off the PHP topic but I've seen similar questions so I'll post it anyway.

    I want to make a file archive where when a file link is clicked, it prompts the browser to open the Save As dialog. I've tried doing this by sending the header "Content-type: application/octet-stream" and then sending the file with readfile(). This works fine, however the browser puts my PHP file's name as the default name. I want the linked file's name to be the default.

    Any suggestions??
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    I'm not real sure about this, but it's probably worth a try.. when you pass a file
    via a form element using the enctype="multipart/form-data" you can
    get the name and size and type from a set
    of variables.. if you file field was named
    upload then to get the
    uploaded files information you would use something like:
    $upload_name <-gives the files name
    $upload_type <-gives you the mime/type
    $upload_size <-gives you the file size

    So, you might try using something like that.. again, don't know if it would work, but if you can pass the mime/type through a get statement, then sure you can pass the files name by adding an _name=blah ...

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    damari
    Guest
    Devshed Newbie (0 - 499 posts)
    header("Content-disposition: filename=thefilename.exe");
    header("Content-type: application/octetstream");

    Should send the file as thefilename.exe !

    Regards
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    4
    Rep Power
    0
    Thanks for your help damari but this only works under Netscape. It still has no effect on IE4 (not sure about IE5)!

    Any ideas?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    6
    Rep Power
    0
    I tested it with both IE5 & IE5SP1 with success! But it won't work in IE5/IE5SP1 if you use HTTPS.

    Regards

Similar Threads

  1. Downloading a file from an HTTP Server
    By TJEr in forum ASP Programming
    Replies: 5
    Last Post: January 5th, 2006, 09:35 PM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  3. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 07:06 AM
  4. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 08:42 PM
  5. Replies: 5
    Last Post: January 27th, 2004, 05:22 AM

IMN logo majestic logo threadwatch logo seochat tools logo