473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

PHP Download bug with MP files

43
Here is my php download mp3 script

Expand|Select|Wrap|Line Numbers
  1. header("Pragma: public");
  2. header("Expires: 0");
  3. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Cache-Control: public");
  4. header("Content-Description: File Transfer");
  5. header("Content-Type: audio/mpeg");
  6. header("Content-Disposition: attachment; filename = " . $file_name . ";");
  7. header("Content-Transfer-Encoding: binary");
  8. header("Content-Length: " . filesize($file));
  9. @readfile($file);
and it opens my file ant it starts to download but it don't show how much time left hot to fix it?
Jan 26 '09 #1
13 1607
Markus
6,050 Expert 4TB
@tader
I believe it is up to your web browser to determine the time left for a download, not any headers you set.
Jan 26 '09 #2
Atli
5,058 Expert 4TB
Yep I would have to go with Markus on this one.
You are even sending the Content-Length header, so the browser should have all it needs to calculate this.

Perhaps you need to upgrade your browser?
Just out of curiosity, which browser are you using now?
Jan 26 '09 #3
tader
43
im using Firefox 3.0.5
Jan 28 '09 #4
Markus
6,050 Expert 4TB
@tader
Same version I'm using and anything I download it gives me the remaining time left for it.
Jan 28 '09 #5
tader
43
maybe it's because the file size is big try to open this i tryed this script on other computer is didn't work as well
Jan 28 '09 #6
Markus
6,050 Expert 4TB
@tader
Do you have a link?
Jan 28 '09 #7
tader
43
http://www.mp3talpykla.com/_download.php try yourself but it will work like i said
Jan 28 '09 #8
Atli
5,058 Expert 4TB
I tried this, and it does indeed appear like the "Content-Length" header is not getting through. Both Firefox and Opera download the file as if they do not know it's size.

It's weird tho, because when I request the headers, the Content-Length header is getting sent:
Expand|Select|Wrap|Line Numbers
  1. HEAD /_download.php HTTP/1.1
  2. Host: www.mp3talpykla.com
  3. Connection: close
  4.  
  5. HTTP/1.1 200 OK
  6. Date: Wed, 28 Jan 2009 18:02:22 GMT
  7. Server: Apache/2
  8. X-Powered-By: PHP/5.2.6
  9. Pragma: public
  10. Expires: 0
  11. Cache-Control: public
  12. Content-Description: File Transfer
  13. Content-Disposition: attachment; filename = Roland_Klinkenberg_-_Dusty_Horizon_(Max_Graham_club_mix_(www.mp3talpykla.com).mp3;
  14. Content-Transfer-Encoding: binary
  15. Content-Length: 8003580
  16. Vary: Accept-Encoding,User-Agent
  17. Connection: close
  18. Content-Type: audio/mpeg
One thing that that might be off tho. You add a semi-colon after the filename. It shouldn't be there. Maybe that is causing some parse errors.
Jan 28 '09 #9
tader
43
i deleted it and it don't work!!!
Jan 28 '09 #10
Atli
5,058 Expert 4TB
Ok. I tested your code on my test server, and it works perfectly. I get the time remaining and everything.
http://atli.advefir.com/test/test.php

This is the code I used:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $file = "../hitakutur/Songs/Hitakutur - G-era.mp3";
  3. $file_name = "Hitakutur - G-era.mp3";
  4. header("Pragma: public");
  5. header("Expires: 0");
  6. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7. header("Cache-Control: public");
  8. header("Content-Description: File Transfer");
  9. header("Content-Type: audio/mpeg");
  10. header("Content-Disposition: attachment; filename=\"" . $file_name . "\"");
  11. header("Content-Transfer-Encoding: binary");
  12. header("Content-Length: " . filesize($file));
  13. @readfile($file);
  14. ?>
I only made minor alterations to the Content-Disposition line.
(Added the quotes around the name and removed the extra semi-colon)

So, if this code is in fact not working properly on your server, the server itself must be the problem, not the code.

Did you set the server up yourself?
Jan 28 '09 #11
tader
43
well your example didn't work :|
Jan 30 '09 #12
Atli
5,058 Expert 4TB
@tader
You get the time left when downloading from my server, right?
I did, at least. (using Firefox 3.0.5 on Ubuntu.)

Like I said before, if the code I posted does not work on your server, then there must be a problem with the server.
The code works, the link I provided proves that. You just need to figure out why it doesn't work on your server.

I suggest you contact your host. Perhaps they will know why this is happening.
Jan 30 '09 #13
tader
43
ok than you for you help ;]
Jan 30 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Ken | last post by:
How do I download files from the internet server to my computer? How do I tell the script the correct hard drive folder on my computer to copy the files to? After connecting to the internet...
3
by: Matthew Moran | last post by:
I am creating a series of downloadable articles, career tools, spreadsheets, etc. However, some of the content is for "registered" guest. The registrants are stored in a database and logon. I...
5
by: Stanav | last post by:
Hello all, Thanks in advance for any replies... Now, my question is: Is it possible to do a multiple files download for a single response event on an aspx page? If there is, please give me some...
1
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.