PHPダウンロードファイル


    public function down()
    {

        $run_id=I("run_id"); //    ID
        $pinyin=I("pinyin"); //     

        $w["run_id"]=array("EQ",$run_id);
        //          
        $v=$this->runModel->where($w)->find();
        //    key
        $archivesid=$v["archivesid"];
        //     
        $table_name= $this->typeModel->where("flow_id=".$v["flow_id"])->getField("table_name");
        //        
        $path = D($table_name)->where("archivesid=".$archivesid)->getField($pinyin);
        
        //    
        $arr= explode("/",$path);
        //        
        $len=count($arr)-1;
        //   
        $fileName=$arr[$len];

        //                   r    
        $file = fopen ($path,"r"); 

        //                     
        Header ( "Content-type: application/octet-stream" ); 
        //           
        Header ( "Accept-Ranges: bytes" );
        //       ,            ,         $file_name     。
        Header ( "Content-Disposition: attachment; filename=".$fileName); 
        //Content-Length                       
        Header ( "Accept-Length: " . filesize($path));  

        //                   
        echo fread ( $file,filesize ($path) );    
        fclose ($file);    
        exit ();    
    }