I want to upload a zip file and extract it to a folder using php. I am using this code:
$zip = new ZipArchive;
if ($zip->open($filename) == TRUE){
$zip->extractTo('Articles/');
$zip->close();
$isql="update articles set a_file='$newfile' where a_id='$fpk'";
$urec=mysql_query($isql);
}
else {
echo 'failed';
}
But it is showing these warnings:
Warning: ZipArchive::extractTo() [ziparchive.extractto]: Invalid or unitialized Zip object in D:\xampp\htdocs\Constructor\adminhome.php on line 36
Warning: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object in D:\xampp\htdocs\Constructor\adminhome.php on line 37...
Shall I include the ziparchive library? If yes then how could I do this?
move_uploaded_file()
to move the file into the file system before attempting to open it? – user1864610