Jump to content

Make File ask to be saved as when downloading


snipersteve

Recommended Posts

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!
Link to comment
Share on other sites

I remember reading somewhere that the mime type application/octet-stream would [u]make[/u] 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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.