Here is the best way to check if an uploaded zip archive contains a certain file and if so, extract the entire contents to a directory on your server:
Please see right hand panel before copying>
$zipFile=$_FILES["your file field name here"];
$checkFile="doesThisFileExist.html";
$exractPath="directory/to/extract/zip";
if($zipFile["error"] == UPLOAD_ERR_OK){
if(strchr($zipFile['tmp_name'],'.zip')){
$zip = new ZipArchive;
$res = $zip->open($zipFile["tmp_name"]);
if ($res === TRUE) {
if(is_numeric($zip->locateName($checkFile))){
$zip->extractTo($exractPath);
//put extra functions here if you want
$zip->close();
}else{
echo "ERROR: Uploaded zip archive is missing a required file!";
}
}else{
echo "ERROR: Could not open uloaded zip archive";
}
}else{
echo "ERROR: Uploaded file is not a zip archive"
}
}else{
echo "ERROR: The upload was not successful";
}
3 comments:
No you did not help me!
coach outlet
michael kors handbags
longchamp bags
adidas nmd
michael kors outlet online
polo ralph lauren outlet online
cheap mlb jerseys
coach factory outlet
cheap uggs
cheap uggs
20161228caiyan
pg เว็บสล็อต สมัคร ฟรี ฟรี สมัคร PG SLOT กับเว็บไซต์ของเรา รับโปรโมชั่นดีๆที่หาไม่ได้จากที่อื่น พร้อมทั้งระบบการสมัครสมาชิกที่รองรับให้ท่านสามารถสมัครได้อย่างรวดเร็ว ผ่านทางระบบออโต้
Post a Comment