php download file slows

Posted by hobbywebsite on Stack Overflow See other posts from Stack Overflow or by hobbywebsite
Published on 2012-12-18T22:55:22Z Indexed on 2012/12/18 23:03 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

OK first off thanks for your time I wish I could give more than one point for this question.

Problem: I have some music files on my site (.mp3) and I am using a php file to increment a database to count the number of downloads and to point to the file to download. For some reason this method starts at 350kb/s then slowly drops to 5kb/s which then the file says it will take 11hrs to complete. BUT if I go directly to the .mp3 file my browser brings up a player and then I can right click and "save as" which works fine complete download in 3mins. (Yes both during the same time for those that are thinking it's my connection or ISP and its not my server either.)

So the only thing that I've been playing around with recently is the php.ini and the .htcaccess files.

So without further ado, the php file, php.ini, and the .htcaccess:

download.php

<?php

include("config.php");
include("opendb.php");

$filename = 'song_name';
$filedl = $filename . '.mp3';      

$query = "UPDATE songs SET song_download=song_download+1 WHER song_linkname='$filename'";          
mysql_query($query);

header('Content-Disposition: attachment; filename='.basename($filedl));
header('Content-type: audio/mp3');
header('Content-Length: ' . filesize($filedl));
readfile('/music/' . $filename . '/' . $filedl);

include("closedb.php");
?>

php.ini

register_globals = off
allow_url_fopen = off

expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="


; Defines the default timezone used by the date functions
date.timezone = "America/Los_Angeles"

.htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www.MindCollar.com)?$ [NC]
RewriteRule (.*) http://www.MindCollar.com/$1 [R=301,L]

<IfModule mod_rewrite.c>
RewriteEngine On
ErrorDocument 404 /errors/404.php
ErrorDocument 403 /errors/403.php
ErrorDocument 500 /errors/500.php
</IfModule>

Options -Indexes
Options +FollowSymlinks

<Files .htaccess>
deny from all
</Files>

thanks for you time

© Stack Overflow or respective owner

Related posts about php

Related posts about .htaccess