I searched for the problem everywhere but I didn't find similar problem.
I create a zip file with the following code. The capacity of the zip file seems to be normal as it has file. I can see the files in my zip when I double click it. But when I extract the zip file, I see that the files have been added in two different directories and my files too.
Let me explain in more detail below.
$files = array(
'bauhaus93regular-1519481745.382.ttf' => '../../../files/task_files/bauhaus93regular-1519481745.382.ttf',
'dsc_0299-1518894123.175.jpg' => '../../../files/task_files/dsc_0299-1518894123.175.jpg',
'sertifika-1518371071.2923.pdf' => '../../../files/task_files/sertifika-1518371071.2923.pdf'
);
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $key=>$file) {
$zip->addFile($file, $key);
}
$zip->close();
header('Content-Description: File Transfer');
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($zipname));
ob_clean();
readfile($zipname);
ob_flush();
With this I can download the file as file.zip. If I click twice, my files in it. But it's size is 14,9 MB. When I extract the zip, I can see all my files, but the files are in two different directories and with them;
files/task_files/(my_files)
xampp/htdocs/contract/files/task_files/(my_files)
(my_files)
First directory is my localhost adress and second one is phisical directory on my harddrive and my files again.
I am very glad if you help. Thanks in advance.
Note that; PHP version is 5.7 due to necessity.