首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

1G资料在服务器上可以正常下载,但超过4G就下载后文件为0kb

2013-03-26 
1G文件在服务器上可以正常下载,但超过4G就下载后文件为0kb本帖最后由 molaifeng 于 2012-10-15 16:43:27

1G文件在服务器上可以正常下载,但超过4G就下载后文件为0kb
本帖最后由 molaifeng 于 2012-10-15 16:43:27 编辑


//此为下载文件
function download($file_dir,$file_name)
    {
        $file_dir = chop($file_dir);// remove of the more space
        // get the download file
        if($file_dir != '')
        {
            $file_path = $file_dir;
            if(substr($file_dir,strlen($file_dir)-1,strlen($file_dir)) != '/')
                $file_path .= '/';
            $file_path .= $file_name;
        }            
        else
            $file_path = $file_name;    
        
        // judge the download file exist
        if(!file_exists($file_path))
        {
            echo 'Sorry,the file not exist';
            exit;
        }
        
        $file_size = filesize($file_path);
       
        header("Content-type: application/octet-stream");
        header("Accept-Ranges: bytes");
        header("Accept-Length: $file_size");
        header("Content-Disposition: attachment; filename=".$file_name);
        
        $fp = fopen($file_path,"r");
        $buffer_size = 1024;
        $cur_pos = 0;
        
        while(!feof($fp)&&$file_size-$cur_pos>$buffer_size)
        {
            $buffer = fread($fp,$buffer_size);
            echo $buffer;
            $cur_pos += $buffer_size;
        }
        
        $buffer = fread($fp,$file_size-$cur_pos);
        echo $buffer;
        fclose($fp);
    }
$file_path = "../data/";
    // with the function
if(file_exists($video)){
download($file_path, "atrcd.tar");


}

`sudo /usr/local/asg/www/scripts/www-misc remDownloadFile`;  //移除服务器上的压缩文件


[解决办法]
系统盘是FAT32格式的不支持下载超过4G的文件
[解决办法]
32位的机器吧, 4G是off_t能表示的最大值了,也就是说32位的机器不能操作4G以上的文件。
[解决办法]
恩 总之就是文件系统不支持大于4G的文件
ext2也不支持吧

热点排行