0
我有一個ZIP文件(帶有VPK擴展名),我希望提取壓縮文件目錄中的文件。上傳的文件正確上傳。這是我目前的代碼。但不幸的是它引發了一個錯誤。從一個目錄中讀取ZIP文件中的單個文件
$hbid = substr(md5(time()),0,16);
mkdir("pkg/".$hbid, 0700);
mkdir("pkg_image/".$hbid, 0700);
$target_dir = "pkg/" . $hbid . "/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
...
FILE UPLOADING CODE HERE
...
ERROR -> $handle = fopen('zip://./'.$target_file.'#/sce_sys/icon0.png', 'r');
$result = '';
if($handle){
while (!feof($handle)) {
$result .= fread($handle, 8192);
}
fclose($handle);
$file = fopen("pkg_image/".$hbid."/icon0.png");
fwrite($file,$result);
fclose($file);
錯誤代碼是這樣的:
fopen(zip://./pkg/0152cc9c0c52da70/4rows_1_1.vpk#/sce_sys/icon0.png): failed to open stream: operation failed
我從來沒有提取的文件,這種方式之前,但在看與此相關的其他答案,他們都從zip的根中提取一個文件,但我需要的文件位於zip文件的子目錄中。我不完全確定我做錯了什麼。
謝謝。