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?
A:
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!
RageD
2010-07-11 00:22:31
That's not applicable. There is no file resource to pass to the filesize() method. Remember, I want to get the filesize of the attachment BEFORE downloading it.
StackOverflowNewbie
2010-07-11 00:42:16
A:
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.
Slartibartfast
2010-07-11 02:40:17
I'm using Zend Mail library. Currently downloading from POP3, but would like a solution that works for other protocols.
StackOverflowNewbie
2010-07-11 02:43:59
http://framework.zend.com/apidoc/1.10/Zend_Mail/Protocol/Zend_Mail_Protocol_Pop3.htmlIt looks like you'll need to find another library if you want something protocol independent (the two protocols don't share any useful (for this) common methods)
Slartibartfast
2010-07-11 03:46:39