Damaged Downloaded Zip Files

二次信任 提交于 2020-07-31 04:19:13

问题


i've made a PHP form which contains an input[type=file] that only accepts zip format files. the zip file successfully uploads when the form is submitted. i have also created a download link for admin to download the file which has uploaded by the user. the problem is when the file is downloaded it has this error with it => "the archive is either in unknown format or damaged"

i would be thankful if you help me

here is my code :

if (!empty($_FILES)){
    foreach ($_FILES as $key=>$file){

        $fileName = $file['name'];
        $fileTmp = $file['tmp_name'];

        $fileExt = explode(".",$fileName);
        $fileActualExt = strtolower(end($fileExt));

        $allowed = ['zip'];
        if (in_array($fileActualExt,$allowed)){
            $newFileName = $requestId."-".$key."-".$_SESSION['user_id']."-planForm".".".$fileActualExt;
            $newFileLocation = "../mehrdadfit/img/plan-form/$newFileName";
            move_uploaded_file($fileTmp,$newFileLocation);
        }
    }
}

来源:https://stackoverflow.com/questions/62877165/damaged-downloaded-zip-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!