Twango Posted March 31, 2011 Share Posted March 31, 2011 This morning, I had a working php script. Simply using header("Content-type:audio/x-wav");header("Content-Disposition:attachment;filename=ASCII.wav");readfile("ASCII.wav"); Now... This morning it was downloading the song properly. But now when I download it, it's only 222 bytes.I haven't changed anything at all... it's really making me mad!I cant figure out why this isnt workingHELP Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2011 Share Posted March 31, 2011 Add a content-length header to tell the browser how much data to expect. Have you verified that the wav file is not that small? Link to comment Share on other sites More sharing options...
Twango Posted March 31, 2011 Author Share Posted March 31, 2011 Yes, I have verified that. Because before it was downloading it 24MB... anyway how do I do the "content length header"? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2011 Share Posted March 31, 2011 The header function will add any header. The content-length header should list the length of the data in bytes. You should be able to use the filesize function to get the size of the file. There's an example here:http://en.wikipedia.org/wiki/Content-Length Link to comment Share on other sites More sharing options...
Twango Posted March 31, 2011 Author Share Posted March 31, 2011 Still isnt working... I made another page to get the value in bytes; here's the code I have now.header("Content-Disposition:attachment;filename=ASCII.wav;content-length:27770924");It's still download 222 bytes! Link to comment Share on other sites More sharing options...
Twango Posted March 31, 2011 Author Share Posted March 31, 2011 Now that I think about it that could be glitchy; here's my full code NOW....header("Content-type:audio/x-wav");header("Content-Disposition:attachment;filename=ASCII.wav");header("Content-Length:27770924"); Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2011 Share Posted March 31, 2011 Technically, you're supposed to have a space after the colon after the header name. e.g.:header('Content-type: application/octet-stream');header('Content-Disposition: attachment; filename="report.csv"'); Link to comment Share on other sites More sharing options...
Twango Posted March 31, 2011 Author Share Posted March 31, 2011 It's downloading the OTHER one fine... Two files; one works fine, the other one doesn't... WHY!? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2011 Share Posted March 31, 2011 What is the complete code on the page? Open the 222 byte file you downloaded in a text editor and see if it contains an error message. Link to comment Share on other sites More sharing options...
Twango Posted April 1, 2011 Author Share Posted April 1, 2011 Ooookay that's odd... it just started working... changed nothing at all. strange. Link to comment Share on other sites More sharing options...
ColdEdge Posted April 2, 2011 Share Posted April 2, 2011 If your host supports it I would suggestion using zlib.output compression as well as the flush() method if($_GET['mode'] == 'export' && $_GET['dl'] == '1') {if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');$044467d6c7609f0c48bbfa6b4e6a1202 = mysql_query("SELECT * FROM files WHERE token = '".$10bbf6d474e63a7580069a78e2690fe9."'");$cf_rows = mysql_fetch_array($044467d6c7609f0c48bbfa6b4e6a1202);$128263007e9a21197bc41887abdaeb97 = $cf_rows['file'];$size = $cf_rows['size'];$name = $cf_rows['name'];$type = $cf_rows['type'];$oath = $cf_rows['aoth_tkn'];if($0b77a7157d890651d8be9867aff97a52 != 09bfa665212399c841c8e844dc29a4e6($0b06d2f4f9f2c06c1dc3255b9ea877d2])) { exit();} else {header("Pragma: public"); // requiredheader("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Cache-Control: private",false); // required for certain browsersheader("Content-Type: ".$type."");header("Content-Transfer-Encoding: binary"); header("Content-Disposition:attachment;filename=".$name."");header("Content-Length: ".$size);ob_clean(); flush();$fp = fopen($128263007e9a21197bc41887abdaeb97, "r"); while (!feof($fp)){ echo fread($fp, 65536); flush(); // this is essential for large downloads} fclose($fp);#readfile("".$128263007e9a21197bc41887abdaeb97."");}}} The attachment location will not be shown and not only that but my attachments are hashed via md5 and then uploaded to web server however during downloading you get original file name with fake path ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.