Since the latest versions of Access (2007/2010) it's possible to add attachments to rows. I have such a database with members and their photos, but i would like to export them (including photos) and use them for a new webapplication. I have made a XML-export with Access 2007. The photos which i have attached are encoded in the XML export.
由于最新的访问版本(2007/2010),可以将附件添加到行中。我有这样一个数据库,里面有成员和他们的照片,但是我想要导出它们(包括照片),并使用它们作为一个新的webapplication。我已经用Access 2007创建了一个xml导出。我附上的照片在XML导出中被编码。
Please find below an example of the file smiley.jpg, which i have attached in a random row in my database. (The original file smiley.jpg you may find back here: http://img812.imageshack.us/img812/8248/smileyq.jpg)
下面是一个文件smiley.jpg的示例,我已经将它附加在数据库中的一个随机行中。(原始文件smiley.jpg,您可以在这里找到:http://img812.imageshack.us/img812/8248/smileyq.jpg)
<Foto>
<FileData>FAAAAAEAAAAEAAAAagBwAGcAAAD/2P/gABBKRklGAAEBAQBkAGQAAP/bAEMAAwIC
AwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQV
FRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQU
FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIACgAKAMBIgAC
EQEDEQH/xAAbAAACAgMBAAAAAAAAAAAAAAAABgUHAQgJA//EADIQAAIABAMFBgYC
AwAAAAAAAAECAwQFEQAGEgcTFSExCBRRYYGRCSIkMkGxM3GCodH/xAAYAQADAQEA
AAAAAAAAAAAAAAAEBQgHBv/EACgRAAIBAwMDBAIDAAAAAAAAAAECEQADBAUhMQYS
QQciYYETURRxkf/aAAwDAQACEQMRAD8A6nxoyS8Mu5soxAz1VnI9xBPd4fiBdj64
KpP7+omCD8kHl/l+f+Y0T+KR2m9ofZ+puziHkKomi8Um5qPOTywEi69wIOiCdakB
W3rEjqdAF7XxmWp6te1TLOlafd7GkiZiSASdxuAIjbmjUthF73FbnzMSoKxZZ+YD
eG9NvbBI5yqFMihZ0d8l782AAdR+j6++FSo5xqSbIouaBTTxhaEakKaQf5+77zdW
6/d8vjjUT4aHaJz92gKDtAXPdQasmlzktElJ5oCQiN+IpeCNCgWTdqQOo126WxO7
6h1FgWcnWsDLITHZAwLEz3tA9pkHfmfqmwS0xW2y810ekp2DUZZJiXiCJCcXDDBh
GyZUGp1ZMizfTzNyoPQOBe/qBb2wYp/o/qW31VpKZ6jtee1x+mETHwQQR8GKS5Fk
2LhWstMlavPq33CO/tqNsQGYMv5U2nU+Xh1qj0vMsnIzpiwUqEqkwkGZguyFlDgg
OrBluPMYlNodBVp12imOslO21NLx3gsHFrjWhDC9gevPmOmKRg54idngvR80S802
zxXZqTmaWgvHh02ETcSs6FBaGqE6UjkFCmkOVZbvKGvPn4Gr5eEs/mVyVA2LKSSC
vkkggwN4mJinloK1tW8VeUaNqwq0LLGVtmdOiwKLSKZlqRnJwRIkOnyqS8OLMRWC
BmCAAszFVuevIeGIM9oHZeKXxI7RsqcP06u88altFv714Uouc37Q8SHS8tSs1D2d
7xYlUzJNQXgJU0Uhu6ySuAzo5ADx7BdGpULM2pM2/i5+QzNkq1u1PuJBA2/uAW57
V5J480Z3IONzV0St+P0zT92/T2uL/wCsGPfZ3l9EnUeFv2k5LUEaYjvGdnN+RdyW
NrnqeXIdMGK49HtOvYehXL9wELdclZ2lQAJ+yD/lIdQcNdAHgVYU9IwKlKvLzCCJ
Cccwf2PPCNUMm1Gmuxk/rZf8C4DgeYPI+ntgwY7vqjo/Sep7U56HvUbOphgOYmCC
Pggx4ihrGRcsn2mkYbI8vCrcQGz2liqatffODQt7q8d5ovfzvh5p+TajUnUzv0Uv
+VuC5HkOg9fbBgxknTvp1o2bktczGuXRb4VmEfcAGPgEUdey7irCwJp6kZGDTpVJ
eXQQ4SCwA/Z88GDBikbVpLKLatKFVRAA2AA4AH6pQSSZNf/Z
</FileData>
<FileName>smiley.jpg</FileName>
<FileType>jpg</FileType>
</Foto>
It seems to be encoded with base64, but as soon as i try to decode it using the PHP function base64_decode(), i don't get a valid output back. I have found some additional data back in the XSD-file, which is automatically generated when you make an XML-export in Access. There it seems to refer to base64, so i don't know what's going wrong.
它似乎是用base64编码的,但是当我尝试用PHP函数base64_decode()解码它时,我就得不到有效的输出了。我在xsd文件中找到了一些额外的数据,这些数据是在您访问xml导出时自动生成的。在这里,它似乎是指base64,所以我不知道哪里出了问题。
<xsd:element name="FileData" minOccurs="0" od:jetType="oleobject" od:sqlSType="image">
<xsd:simpleType>
<xsd:restriction base="xsd:base64Binary">
<xsd:maxLength value="1476395008"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
I have tried the following code, to get the image back ($data is filled with the encoded stuff from the XML-export):
我已经尝试了下面的代码,以获取图像($data从xml导出中填充了编码的内容):
<?php
header('Content-Type: image/jpeg');
echo base64_decode($data);
?>
I have looked on several websites, but i can't find a solution for this issue. It seems that Access is also compression the data, because it's impossible to get the original file back. I hope someone on * will have a solution for this issue!
我已经看了几个网站,但我找不到解决这个问题的办法。访问似乎也压缩了数据,因为无法返回原始文件。我希望*的人能解决这个问题!
The main goal is to export approx. 2500 members (with photos attached) from Access 2007. The data can be exported easily, but it's all about the photos which make it complicated.
其主要目标是输出approx。2500名成员(附照片)从2007年进入。这些数据可以很容易地导出,但是所有的照片都很复杂。
1 个解决方案
#1
1
It's seems, that 1st 20 bytes of decoded file is some service info.
似乎,第一个20字节的解码文件是一些服务信息。
Try something like this (this is not ideal, but you understand the idea):
试着这样做(这不是理想的,但你理解这个想法):
echo substr(base64_decode($data), 20);
#1
1
It's seems, that 1st 20 bytes of decoded file is some service info.
似乎,第一个20字节的解码文件是一些服务信息。
Try something like this (this is not ideal, but you understand the idea):
试着这样做(这不是理想的,但你理解这个想法):
echo substr(base64_decode($data), 20);