I pasted a copy of a code that someone shared on this site for forcing downloads. I tested out for downloading mp3 files. When you click on the link for calling the php code it does prompt you and asks if you want to open or save the file. The file type shows as "mp3" however the file size says 221 bytes. I know that the file is about 20MB.<br /><br />If I click on Save, it prompts me to save to my local hard drive. The "Save as Type" shows up, by default, as HTML document. Why would it do that? This is an mp3 file. Even if I change it to "All Files" and save it as an mp3, it doesn't play. I get an error saying it doesn't recognize the file.<br /><br />Anyone one have a diagnosis?<br /><br />CODE<?php<br />ini_set('session.cache_limiter', '');<br />header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');<br />header('Cache-Control: must-revalidate, post-check=0, pre-check=0');<br />header('Pragma: no-cache');<br /><br />header("Content-Disposition: disposition-type=attachment; filename=movie.wmv");<br /><br />readfile("http://www.remotedomain.com/movie.wmv");<br /><!-- the movie,mp3,mpeg file can be sitting on a remote domain and you just call to it. --><br />?><br /><br />Code for the calling link:<br />CODE<html><br /><head><br /><title>Testing Movie Download</title><br /></head><br /><br /><body><br /><br /><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"/path/to/script.php">Download Movie</a><br /><!-- Where script.php is stored on your domain --><br /><br /></body><br /></html><br /><!--content-->
Hey,<br /><br />Im sure there are more header variables you have to set than that...<br /><br />try looking here: <a href="http://www.phpit.net/code/force-download/" target="_blank">http://www.phpit.net/code/force-download/</a><br /><br />and adding in the missing headers... most notably i think is the missing mimetype/content-type<br /><br /><br />obviously I can't guarantee this code works as I didn't write it, but worth a shot?<!--content-->
Welcome to the forum, MichiKen. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Welcome to the forum MichiKen <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Hey,<br /><br />Im sure there are more header variables you have to set than that...<br /><br />try looking here: <a href="http://www.phpit.net/code/force-download/" target="_blank">http://www.phpit.net/code/force-download/</a><br /><br />and adding in the missing headers... most notably i think is the missing mimetype/content-type<br /><br /><br />obviously I can't guarantee this code works as I didn't write it, but worth a shot?<!--content-->
Welcome to the forum, MichiKen. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Welcome to the forum MichiKen <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->