CURL を使用してリモート サーバー上の zip ファイルの内容を取得し、それを temp_zip_file.zip に保存してから、PclZip クラスを使用してファイルの内容を抽出しています。
問題は、一部のサーバーでは、スクリプトが CURL リターンから一時的な zip ファイルを作成することをサーバーが許可しないため、それを pclzip 抽出に使用できることです。
私がやりたいことは、一時的な zip ファイルの作成をスキップし、元の CURL の文字列リターンと pclzip クラスを抽出に使用することです。
一部のサーバーではデフォルトのphp zipクラスの使用が許可されていないため、pclzipを使用する必要があります。
以下は、リモート ファイルからコンテンツを取得するために使用される curl 関数です。
function copy_file($download_file)
{
//get file
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$download_file);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$file = curl_exec($ch);
curl_close($ch);
$fp = fopen('temp_zip_file.zip', 'w');
fwrite($fp, $file);
fclose($fp);
//exit;
}
以下は、$download_file が「temp_zip_file.zip」である、私の pcl unzip 関数のコピーです。
function zip_extract($download_file, $store_path, $remove_path)
{
//echo 1; exit;
//echo $remove_path; exit;
$archive = new PclZip($download_file);
$list = $archive->extract(PCLZIP_OPT_REMOVE_PATH, $remove_path, PCLZIP_OPT_PATH, $store_path, PCLZIP_OPT_REPLACE_NEWER );
if ($list == 0)
{
//echo "death here"; exit;
die("Error : ".$archive->errorInfo(true));
}
else
{
//print_r($list); exit;
return 1;
}
}
ご支援ありがとうございます