从压缩文件中获取图像的高度和宽度
getNameIndex($i)我目前正在使用 zip 存档函数来提取一些图像,我正在寻找一种给出每个图像的文件路径的方法,以便我可以使用 getimagesize 来获取宽度和高度,下面是正在使用的方法循环遍历文件。
$chapterZip = new ZipArchive();
if ($chapterZip->open($_FILES['chapterUpload']['tmp_name']))
{
for($i = 0; $i < $chapterZip->numFiles; $i++) {
list($width, $height) = getimagesize(getNameIndex($i));
$imageLocation= "INSERT INTO imageLocation (imageLocation,imageWidth,imageHeight,chapterID) VALUES ('"."Manga/".$_POST['mangaName']."/".$_POST['chapterName']."/".$chapterZip->getNameIndex($i)."',".$width.",".$height.",".$chapterID.")";
getQuery($imageLocation,$l);
}
if($chapterZip->extractTo("Manga/".$_POST['mangaName']."/".$_POST['chapterName']))
{
$errmsg0.="You have successfully uploaded a manga chapter";
$chapterZip->close();
}
}
对此的任何帮助将不胜感激!
getNameIndex($i)I am currently using the zip archive function to extract some images, I am looking for a method which gives the filepath of each individual image so I can use getimagesize to get the width and height, below is the method am using to loop through the files.
$chapterZip = new ZipArchive();
if ($chapterZip->open($_FILES['chapterUpload']['tmp_name']))
{
for($i = 0; $i < $chapterZip->numFiles; $i++) {
list($width, $height) = getimagesize(getNameIndex($i));
$imageLocation= "INSERT INTO imageLocation (imageLocation,imageWidth,imageHeight,chapterID) VALUES ('"."Manga/".$_POST['mangaName']."/".$_POST['chapterName']."/".$chapterZip->getNameIndex($i)."',".$width.",".$height.",".$chapterID.")";
getQuery($imageLocation,$l);
}
if($chapterZip->extractTo("Manga/".$_POST['mangaName']."/".$_POST['chapterName']))
{
$errmsg0.="You have successfully uploaded a manga chapter";
$chapterZip->close();
}
}
any help with this would be greatly appreciated !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 PHP 的 Zip 扩展的流包装器,不必手动提取所有文件:
With PHP's Zip extension's stream wrapper, do not have to manually extract all files: