借助下面给出的代码,我可以将邮件附件下载到服务器上的文件夹中
$location="downloads/";
foreach($attachments as $attachment)
{
if($attachment['is_attachment'] == 1)
{
$filename = $attachment['name'];
if(empty($filename)) $filename = $attachment['filename'];
if(empty($filename)) $filename = time() . ".dat";
$fp = fopen("$location" . $msgno . "" . $filename, "w+");
fwrite($fp, $attachment['attachment']);
fclose($fp);
}
}
通过上面的代码在服务器上下载的文件,我希望在系统上下载相同的文件。有人能告诉我如何做到这一点吗?
步骤1。确保包含文件的文件夹位于web服务器中步骤2。将以下代码添加到该文件夹中的.php文件中步骤3。修改要在$files = glob("*.php");
第3行列出的文件的扩展名
<?php
$directory = "/home/trevor/www/t/";
$files = glob("*.php");
foreach($files as $file)
{
echo "<a href=$file>".basename($file)."</a><br />";
}
?>