11 Kasım 2014, 05:01
#1 Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
Sitenizden download edilen dosyanın indirilme hızını belirlemek
PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
<?
$filename = 'file-to-download.zip' ;
// filename visible for client
$visible_name = 'client-file-name.zip' ;
// setting the download rate limit (=> 36,6 kb/s)
$download_rate = 36.6 ;
// checking if file exists
if( file_exists ( $filename ) && is_file ( $filename )) {
// send headers
header ( 'Cache-control: private' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Length: ' . filesize ( $filename ));
header ( 'Content-Disposition: filename=' . $visible_name );
// flush content
flush ();
// open file stream
$file = fopen ( $filename , "r" );
while(! feof ( $file )) {
// send the current file part to the browser
print fread ( $file , round ( $download_rate * 1024 ));
// flush the content to the browser
flush ();
// sleep one second
sleep ( 1 );
}
// close file stream
fclose ( $file );
}
else {
die( 'Error: The file ' . $visible_name . ' does not exist!' );
}
?>
__________________
Bu kez pek bir afili yalnızlık, ağlatan bir kadın kadar düşman. Ağzı bozuk üstelik bırakmıyor acıtmadan.