我想用imap_body
创建一个附件文件数组。这是我如何获得imap_body
:
--001a11c2a20cbdfb1c04f7653888
Content-Type: multipart/alternative; boundary=001a11c2a20cbdfb1b04f7653887
--001a11c2a20cbdfb1b04f7653887
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
bmV3IHRlc3QNCg0KcmVkIGlzIGZpcnN0DQoNCltpbWFnZTog16rXnteV16DXlCDXnteV15jXkdei
16ogMV0NCg0KDQp0aGFuIGdvZXMgYmxhY2sNCg0KW2ltYWdlOiDXqtee15XXoNeUINee15XXmNeR
16LXqiAyXQ0KDQphbmQgdGhhbiByb2kNCg0KW2ltYWdlOiDXqtee15XXoNeUINee15XXmNeR16LX
qiAzXQ0K
--001a11c2a20cbdfb1b04f7653887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
new test
=
red is first
3D"=D7=AA=D7=9E=D7=95=D7=A0=D7=
than goes black
3D"=D7=AA=D7=9E=D7=95=D7=A0=D7=94
and than roi
--001a11c2a20cbdfb1b04f7653887--
--001a11c2a20cbdfb1c04f7653888
Content-Type: image/jpeg; name="black.jpeg"
Content-Disposition: inline; filename="black.jpeg"
Content-Transfer-Encoding: base64
Content-ID:
X-Attachment-Id: ii_1457a2ac29603915
/9j/4AAQSkZJRgABAQEBLAEsAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdC
IFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAA
AADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFj
cHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAA
.....
.....the base 64 is very long so i cut it for the example
.....
M2bDL8tmi/skEPyQzb/9KF/ZoIfkbm1/6OL+yQT/ACQzb/8AShf2a8xH9/JLN/8A9MD/AGa9D8ks
3/8A0wP9mg/v5K2F/wCnC/s0EvyZsT/04P8AZoJfk5ZH+xM/cgmOxbLHk/Mh/uQTyWfDH8gUGSgL
0OT96CdNnVyIP6gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIP//Z
--001a11c2a20cbdfb1c04f7653888
Content-Type: image/jpeg; name="red.jpeg"
Content-Disposition: inline; filename="red.jpeg"
Content-Transfer-Encoding: base64
Content-ID:
X-Attachment-Id: ii_1457a2a811de3322
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYF
BgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoK
CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAHNAmcDAREA
.....
..... again the base 64 is long so i cut it for the example
.....
QBAEAQBAEAQBAEAQBAEAQBAf/9k=
--001a11c2a20cbdfb1c04f7653888
Content-Type: image/jpeg; name="roi.jpg"
Content-Disposition: inline; filename="roi.jpg"
Content-Transfer-Encoding: base64
Content-ID:
X-Attachment-Id: ii_1457a2aef606ba6d
/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABt
bnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFla
...
....
.... the end look like this
pgaKQVBLlxaYlxXSPEQiyvtAWclft/Mdo/M1y6Z0e8UZncAksFR+JYqv4ndXfiIc/ggxf6Ubq/Sm
C/0oX/xQRj8ENoxPX4oAdPxCjRUuXiOF3LzFcS25pwbFcPN1CLw8o32RWQZpGDKtbGyOoizQ4hWZ
tNSefA3NzSDcrMHC47gog4WZpN49zVmz1f/Z
--001a11c2a20cbdfb1c04f7653888--
我构建了一个将内容解码为utf-8的函数。现在我只需要用base64替换图像。现在它看起来像这样:
<img src="cid:ii_1457a2ac29603915" />
and i want to replace it like this
<img src="data:image/jpeg;base64,...." />
因此,如果我拥有我需要的数组,那么很容易进行替换。我想创建一个如下所示的数组:
Array
(
[0] => Array
(
[filename] => black.jpeg
[cid] => ii_1457a2ac29603915
[Content-Disposition] => inline
[encoding] => base64 (get it from "Content-Transfer-Encoding")
(
[file] => the base 64 of the file / image
)
)
[1] => Array
(
[filename] => red.jpeg
[cid] => ii_1457a2a811de3322
[Content-Disposition] => inline
[encoding] => base64 (get it from "Content-Transfer-Encoding")
(
[file] => the base 64 of the file / image
)
)
[2] => Array
(
[filename] => roi.jpg
[cid] => ii_1457a2aef606ba6d
[Content-Disposition] => inline
[encoding] => base64 (get it from "Content-Transfer-Encoding")
(
[file] => the base 64 of the file / image
)
)
)