亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

文件的上傳和下載

??? 2019-02-21 14:43:11 284
????://文件的下載function dowFile($fileName){ //    header( "Content-Disposition:  attachment;  filename=".$fileName); //告訴瀏覽器通過附件形式來處理文件 // 

//文件的下載

function dowFile($fileName){
//    header( "Content-Disposition:  attachment;  filename=".$fileName); //告訴瀏覽器通過附件形式來處理文件
//    header('Content-Length: ' . filesize($fileName)); //下載文件大小
//    readfile($fileName);  //讀取文件內容
    header('Accept-length:'.filesize($fileName));
    header( "Content-Disposition:  attachment;  filename=".basename($fileName));
    readdFile($fileName);
}

//文件的上傳

function upLodFile($fileInfo,$fulePath = './upload',$maxSize = 1000000,$allowExt = ['png','jpg','jpeg','txt']){
    if($fileInfo['error'] === 0){
        $ext = strtolower(pathinfo($fileInfo['name'],PATHINFO_EXTENSION));
        if(!in_array($ext,$allowExt)){
            return '文件格式不正確';
        }
        if($fileInfo['size']>$maxSize){
            return '文件太大'.$fileInfo['size'];
        }
        //判斷文件上傳方式
        if(!is_uploaded_file($fileInfo['tmp_name'])){
            return '文件非法上傳';
        }
        if(!file_exists($fulePath)){
           mkdir($fulePath,0777,true);
        }
        //md5生成唯一文件名 uniqid唯一當前時間戳微秒值
        $path = md5(uniqid(microtime(true),true)).'.'.$ext;
        $dest = $fulePath.'/'.$path;
        if(!move_uploaded_file($fileInfo['tmp_name'],$dest)){
            return '文件上傳失敗';
        }
        return '文件上傳成功';
    }else{
        return '失敗error = '.$fileInfo['error'];
    }

}


?? ???:韋小寶?? ??:2019-02-21 14:55:45
???? ??:寫的很不錯 文件的上傳和下載基本上網(wǎng)站中都有 一定要好好掌握!

??? ??

?? ??