Jump to content

Recommended Posts

Posted

I recently put all of the videos on my site on Google Video, but I want people to still be able to download the (much better looking) .MOV versions that I keep on the site; however, without "save target as"-ing (and it's FireFox, Opera, etc, etc equivalents), the file will stream. Aside from putting the file in a ZIP archive, is there any way to force the download? I haven't found any help elsewhere...

 

Example of one of the pages in question: http://www.sjbmx.com/videos_06assorted.php

Posted

I don't know if you can do that from the programming end of things. I do know that you can change an option within the browser to save rather than run the file. For example, Firefox offers Tools -> Options -> Content -> Manage Files, where you can browse to the .MOV extension and tell it you want to download the files.

Posted

This script has worked for me in the past.

 

><?php
/*  setup  - create a PHP file called fdownload.php with the lines below.

Change the $filedir to point to you path on the server

Call from a link like this: 

<a href="www.******/fdownload.php?file=yourfilename">

*/

$filedir = "/home/yourcpanelname/public_html/";

$file = "$filedir".$_GET['file']."";
if (file_exists(basename($file))) {
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
} else {
echo "$file<br>";
echo basename($file);
echo "<br>No File Found";
}
?>

Posted
This script has worked for me in the past.

 

><?php
/*  setup  - create a PHP file called fdownload.php with the lines below.

Change the $filedir to point to you path on the server

Call from a link like this: 

<a href="www.******/fdownload.php?file=yourfilename">

*/

$filedir = "/home/yourcpanelname/public_html/";

$file = "$filedir".$_GET['file']."";
if (file_exists(basename($file))) {
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
} else {
echo "$file<br>";
echo basename($file);
echo "<br>No File Found";
}
?>

 

Thanks, Bruce. I'll try that out when I get home from work.

  • 2 weeks later...

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...