php - 如何临时从文件夹中复制图像,然后在 PHP 中将其删除?
问题描述
我在 NAS 上有一个包含多个图像的文件夹。我想在文件夹中制作图像的本地副本,显示图像然后删除它们,这样它们就不会接管服务器上的本地。
查看照片后如何删除照片?
我制作了这段代码,但它删除了以下图像,因此无法显示:
<?php
$file = '//Alcyons/it/PhotoShoot/Photos_Outil/A1111_0070_1.jpg';
$newfile = 'A1111_0070_1.jpg';
if (!copy($file, $newfile)) {
echo "La copie $file du fichier a échoué...\n";
}
echo "</td><td valign=top align=center><img src=\"$newfile\" border=0 width=180px></a></td><td width=10></td>";
unlink($newfile);
?>
解决方案
复制文件能解决什么问题?
如果立即删除它有什么意义?
根据您的代码结构,那个会更好:
<?php
$file = '//Alcyons/it/PhotoShoot/Photos_Outil/A1111_0070_1.jpg';
$type = pathinfo($file, PATHINFO_EXTENSION);
?>
</td>
<td valign=top align=center>
<img src="<?php echo "data:image/$type;base64,",
base64_encode(file_get_contents($file)) ?>" border=0 width="180"></a>
</td>
<td width=10></td>
推荐阅读
- jsp - 无法从 jsp 表单将日期时间传递给 google appengine
- tensorflow - A2C中的梯度计算
- r - R Dataframe 创建一个结合行名和列名的新列
- r - ggplot2:具有均值 / 95% 置信区间线的密度图
- r - 重命名 devtools 包中的 R\ 目录
- php - 如何直接在对象上附加关系?
- c++ - 在 MFC 图片控件上无法检测到鼠标按下
- linux - Azure:使用自定义脚本扩展取消配置 linux 实例
- visual-studio - Visual Studio 2019 工具栏 - 更改元素显示大小
- javascript - 在 express 中尝试 catch 块