Jump to content


Photo

Make File ask to be saved as when downloading


  • Please log in to reply
2 replies to this topic

#1 snipersteve

snipersteve
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 July 2006 - 04:27 AM

Hey all. I have a question for you that may or may not be related to PHP.

I have an area on my site where users can download different files. (mainly videos I have created)

Currently I am just pulling the filename from my database, and throwing it into a hyperlink. Of course, when you click on the link the file will start streaming as its a standard video file that Windows Media Player recognizes.

What I want to do is have the window appear where it askes you would you like to save or open the file. The user could then select which they want to do. 


The reasoning behind this is that some of my longer videos are 70+MB and take a while to initilize the stream. I don't want people to think its not working, and would rather give them the option right away to save or open the file.

Thanks!

#2 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 22 July 2006 - 04:48 AM

I remember reading somewhere that the mime type application/octet-stream would make the browser download a file.

Thus, 2 opptions i can see:
Send the file in a PHP script
(something to the effect of:)
header('Content-type: application/octet-stream');
echo @file_get_contents();

or, use a .htaccess file to set your videos to serve as a specific mime type. As i recall, its:
AddType application/octet-stream .wmw
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#3 snipersteve

snipersteve
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 July 2006 - 05:31 PM

I fail:

http://www.phpfreaks...ic,95433.0.html

:( Thanks for your help though!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users