我有一个php页面来处理文件下载的请求.我需要能够检测文件何时成功下载.如何才能做到这一点?也许有一些方法可以检测到这个客户端,然后向服务器发送确认信息.
谢谢.
编辑:通过句柄,我的意思是该页面正在做这样的事情:
$file = '/var/www/html/file-to-download.xyz';
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
Run Code Online (Sandbox Code Playgroud) 我需要保存来自网站的文件HtmlUnit.我目前正在导航到有几个使用javascript onClick()="DownloadAttachment('attachmentId')"获取文件的锚点的页面.这些文件几乎可以是任何类型的文件(xls,doc,txt,pdf,jpg等).到目前为止,虽然我一直无法找到显示如何使用保存文件的资源或示例htmlUnit.我一直在努力AttachmentHandler为此工作,因为它似乎最有可能工作,但一直没有成功.我想知道是否有其他人设法使用下载文件HtmlUnit并可以提供帮助?
我创建了一个Web电子邮件应用程序,如何查看和保存附件?
我正在使用OpenPop,第三方dll,我可以发送带附件的电子邮件和阅读没有附件的电子邮件.
这很好用:
Pop3Client pop3Client = (Pop3Client)Session["Pop3Client"]; // Creating newPopClient
int messageNumber = int.Parse(Request.QueryString["MessageNumber"]);
Message message = pop3Client.GetMessage(messageNumber);
MessagePart messagePart = message.MessagePart.MessageParts[1];
lblFrom.Text = message.Headers.From.Address; // Writeing message.
lblSubject.Text = message.Headers.Subject;
lblBody.Text=messagePart.BodyEncoding.GetString(messagePart.Body);
Run Code Online (Sandbox Code Playgroud)
第二部分代码显示了附件的内容,但只有在它是文本文件时才有用.我需要能够保存附件.我在这里的代码的底部部分写了我的消息正文,所以如果我收到一个附件,我无法查看我的消息正文.
if (messagePart.IsAttachment == true) {
foreach (MessagePart attachment in message.FindAllAttachments()) {
if (attachment.FileName.Equals("blabla.pdf")) { // Save the raw bytes to a file
File.WriteAllBytes(attachment.FileName, attachment.Body); //overwrites MessagePart.Body with attachment
}
}
}
Run Code Online (Sandbox Code Playgroud) 下面的代码只发送一个附件,但我需要附加并发送两个文件(一个rar文件和pdf)
$email_to = "$email"; // The email you are sending to (example)
$email_from = "online@example.co.in"; // The email you are sending from (example)
$email_subject = "subject line"; // The Subject of the email
$email_txt = "text body of message"; // Message that the email has in it
$fileatt = "files/example.rar"; // Path to the file (example)
$fileatt_type = "application/x-rar-compressed"; // File Type
$fileatt_name = "example.rar"; // Filename that will be used for the file as the attachment
$file = fopen($fileatt,'rb'); …Run Code Online (Sandbox Code Playgroud) 我想发送带有PDF附件的电子邮件.我创建了PDF文件,然后我做了以下哪些错误我相信:
// locate folder containing pdf file
let documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] as! String
let pdfFileName = documentsPath.stringByAppendingPathComponent("chart.pdf")
let fileData = NSData(contentsOfFile: pdfFileName)
mc.addAttachmentData(fileData, mimeType: "pdf", fileName: chart)
Run Code Online (Sandbox Code Playgroud)
在发送电子邮件之前,我可以看到附件chart.pdf,但是当我发送电子邮件时,它是在没有附件的情况下发送的,这是因为我没有正确附加文件.
我使用以下标题从我的网络服务器服务器发送html内容为excel
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=test.xls");
Run Code Online (Sandbox Code Playgroud)
我可以在excel版本2013上打开文件,但不能在2016年打开.在2016版本上,它说,The file is corrupt and can not be opened但是一旦我激活File > Properties > Security> Unblock文件打开了吗?是否有任何标题或其他设置我可以指定解锁安全性(或其他配置),以便我能像2013年那样打开excel文件?
我知道之前已经问过这个问题,但我显然需要我的手持.我正在尝试将pdf附加到电子邮件中并将其发送出去.我已经使用PHPMailer在Laravel之外完成了它,但现在我正在尝试使用Laravel方式并且无法使其工作.我在这做错了什么?
这是我得到的错误的开始:
FileByteStream.php第144行中的Swift_IoException:无法打开文件进行读取[%PDF-1.3
public function attach_email($id){
$info = Load::find($id);
$info = ['info'=>$info];
Mail::send(['text'=>'mail'], $info, function($message){
$pdf = PDF::loadView('pdf.invoice');
$message->to('example@gmail.com','John Smith')->subject('Send Mail from Laravel');
$message->from('from@gmail.com','The Sender');
$message->attach($pdf->output());
});
echo 'Email was sent!';
}
Run Code Online (Sandbox Code Playgroud) 有没有办法可以使用PHP的内置SoapClient类为请求添加soap附件?看起来它不支持,但也许我可以手动构建mime边界?我知道PEAR SOAP库支持它们,但是为了使用它我必须重写我的整个库来使用它.
我有一个简单的C#应用程序发送SMTP电子邮件(使用System.Net.Mail类).发送(通过电子邮件发送)MailMessage对象后,我想遍历附件列表并删除与这些附件相关联的原始文件...但我很难找到与每个附件关联的完整文件路径 - 而不保留我的自己的附件文件路径集合.必须有一种从附件对象中提取完整文件路径的好方法.
我知道这一定很简单,但我花了很多时间在这个......时间问别人.
我目前正在使用Papercut来测试通过C#中的SMTP服务器连接发送电子邮件.
我需要发送的电子邮件附有文件,但是当我在Papercut上查看电子邮件时,文件似乎没有出现.我确信这些文件正好附加到电子邮件中,因为我可以在MailMessage对象的附件部分看到它们.我的问题是,Papercut是否支持带附件的电子邮件,还是只显示电子邮件并截断附件?