自动将压缩文件附加并通过电子邮件发送到 PHP,无需用户输入
我编写了一个程序,当它出现错误时,它将错误信息保存在 TEMP 目录中的 zip 文件中,然后打开浏览器访问我的 PHP 文件。
我希望 PHP 文件自动转到特定位置(其临时 zip),该位置将通过 HTTP POST 参数传递,并将 zip 文件夹附加到给我自己的电子邮件中。应该注意的是,我的 mail() 命令连接到 google SMTP 服务器。
这可以做到吗?
如果没有,您有什么建议作为替代方案。我想我可以将二进制数据作为 HTTP Post 传递,然后让 PHP 重新创建 zip?欢迎所有想法。
I have a program I wrote that when it has an error, it saves infomation of the error in a zip file in their TEMP directory, and then opens their browser to my PHP file.
I want the PHP file to automatically go to a specific location (their temp zip) that will be passed via HTTP POST arguments and attach the zip folder to an email to myself. It should be noted that my mail() command is connected to an google SMTP server.
Can this be done?
If not, what do you suggest as an alternative. I suppose I could pass the binary data as a HTTP Post and then have PHP recreate the zip? All ideas are welcomed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您是否可以通过浏览器执行此操作 - 没有浏览器可以在未经用户同意的情况下上传文件 - 这是不安全的,因此是不允许的。
您宁愿尝试连接到服务器,而不是从您的软件打开服务器上的网页,然后以这种方式上传文件 - cURL 将是我认为的选择方法 - 它在大多数编程语言中都有大量的实现,因此这应该不是问题。只需尝试在谷歌上搜索“使用curl上传文件”即可。
I'm not sure you can do that via the browser - no browser can upload a file without users' consent - that's insecure and hence it is not allowed.
You could rather try making a connection to the server, not open the web page on your server, from your software and upload the file that way - cURL would be the method of choice I think - it has plenty of implementations in most programming languages so it shouldn't be a problem. Just try searching for "upload a file with curl" on google.