问题
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