我有一个表单(HTML),它将文件提交到一个PHP脚本,该脚本将文件重命名为ZIP,存储在一个文件夹中(随机名称),然后提取该文件。
文件已上传。
文件夹已正确创建。
文件已正确重命名。
但是解压缩ZIP失败了。
这是我的表单:
<form action="up.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
Select file
<input name="ufile" type="file" id="ufile" size="50" />
<input type="submit" name="Submit" value="Upload" />
</form>
这是 PHP 脚本 - up.php
$file_name = $HTTP_POST_FILES['ufile']['name'];
$random_digit=rand(0000,9999);
$new_file_name=$random_digit.".zip";
mkdir($random_digit, 0777, true);
$path= $random_digit.'/'.$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "The upload is successful<BR/>";
echo "File Renamed to: ".$new_file_name." for processing.<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo "<strong><a style='color:#6A8DBC; text-decoration:none' href='".$link_address."'>Proceed to the next phase of the importation of data to the system</a></strong></br>";
}
else
{
echo "Error";
}
}
$zip = new ZipArchive;
$res = $zip->open($new_file_name);
if ($res === TRUE) {
$zip->extractTo($random_digit.'/');
$zip->close();
echo 'extraction successful';
} else {
echo 'extraction error';
}
是文件夹的模式阻止了提取吗?就我所见,没有语法错误。