I wanna save mail attachments with size in database.
So I open mail in text mode by php,for attachments I can see something like example:
Content-Type: image/jpeg; name="donoghte D2.jpg"
Content-Disposition: attachment; filename="donoghte D2.jpg"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gvn2345e0
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcG BwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwM ...
I will show it by this code
<?php
header('Content-Type: image/jpeg');
echo (base64_decode($text));
?>
If I wanna to calculate the size of this file,and store it and its size in database,what is the best way?
- Should I save encode64 of this(like what sent in mail) in a database?
- If so, what should the datatype of that field be?
- To calculate size of it, should I decode it, then get
strlen
of it? or is there any faster way?
with special thanks for your attention