问题
I'm using Zend Mail library to access email and download email attachments. Is there a way to determine the attachment's filesize before downloading?
回答1:
You don't say how you are 'downloading' it. There are many ways to receive an email. The simplest three are:
- SMTP - No, there is no way,
- POP3 - I think servers typically provide size of the total email, not sure, and
- IMAP - I really don't recall
The answer is in the protocol you are using to retrieve (download). If you don't know that, at least you should know the PHP function you're using, so you should mention that.
回答2:
Have you taken a look at PHP's filesize(); function?
http://php.net/manual/en/function.filesize.php
It prints the file size in bytes but obviously you can convert it to whatever you want!
来源:https://stackoverflow.com/questions/3221322/determine-filesize-of-email-attachment-before-downloading