这里主要是利用php fopen函数来实现读取文件一个个传送到客户本地,有需要朋友可以参考一下,实例代码如下:
- <form method="post">
- <input name="url" size="20" />
- <input name="submit" type="submit" />
- <!-- <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />-->
- </form>
- <?php
- set_time_limit(24*60*60);
- if (!isset($_POST['submit'])) die ();
- $destination_folder = './down/';
- $url = $_POST['url'];
- $newfname = $destination_folder.basename($url);
- $file = fopen($url, "rb");
- if ($file) {
- $newf = fopen($newfname, "wb");
- if ($newf) while (!feof($file)) {
- fwrite($newf, fread($file, 1024*8), 1024*8);
- }
- }
- if ($file) {
- fclose($file);
- }
- if ($newf) {
- fclose($newf);
- }
- ?>
|