Limitare il download di un file - Roberto D'Alessio
I'm specialize in .NET, JAVA, PHP, iPhone App Development, Android App Development, iPad App Development, iOS Development,web design, web developer, web development and IT Solution
iphone development, iphone app development, ipad app development, android development, android app development, iphone app developers, iphone application development, android application development, mobile app development, italy outsource, italy outsourcing company, italy outsourcing companies, italy outsourcing, italy software outsourcing, Italy offshore, software outsourcing, Software testing companies, web design, web developer, web development, IT Solution, wordpress, joomla, angular, angularjs, angular.js, nodejs, node.js, socketio, socket.io, react, ionic, xamarin, hybrid app, web site, development site, site development
31
wp-singular,post-template-default,single,single-post,postid-31,single-format-standard,wp-theme-bridge,cookies-not-set,qode-quick-links-1.0,ajax_fade,page_not_loaded,,qode_grid_1300,qode-content-sidebar-responsive,qode-theme-ver-11.1,qode-theme-bridge,wpb-js-composer js-comp-ver-8.4.1,vc_responsive
Limitare il download di un file
01 Giu Limitare il download di un file
Posted at 06:00h
in
Php
by notelseit
<?php // local file that should be send to the client $local_file = 'test-file.zip'; // filename that the user gets as default $download_file = 'your-download-name.zip'; <hr id="system-readmore" /> // set the download rate limit (=> 20,5 kb/s) $download_rate = 20.5; if(file_exists($local_file) && is_file($local_file)) { // send headers header('Cache-control: private'); header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($local_file)); header('Content-Disposition: filename='.$download_file); // flush content flush(); // open file stream $file = fopen($local_file, "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 '.$local_file.' does not exist!'); } ?>