MS Office 不再作为 BLOB 工作
大家好,有谁知道为什么从 mysql 数据库检索并存储为 Blob 时无法再查看 MS Office(例如 doc、docx 和 xls)吗? doc和docx以前下载打开没有任何问题,但现在不再识别文件格式。
Hi does anyone know why MS Office such as doc, docx and xls can no longer be viewed when retrieved from a mysql db when stored as Blob?
The doc and docx used to download and open without any problem, but now it no longer recognises the file format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想解决你的问题。从 mysql blob 字段上传/下载图像和纯文本文件。 Doc 和 docx 文件似乎已损坏。我在某处读到过有关 mysql 截断最后 4 位的谣言,但我无法验证这一点。
I'd like to ditto your problem. Images and plain text files upload/download from mysql blob field. Doc and docx files seemed to be corrupted. I've read somewhere of a rumor of mysql truncating the last 4 bits but I can't verify that.
我使用 xvi32(十六进制编辑器)将文件的本地原始版本与从 BLOB/LONGBLOB 字段下载的版本进行比较。据 Windows 在写入文件时可以计算出的情况来看,似乎附加了额外的字节,我认为这些字节代表了 CRLF。对于某些在某种程度上具有容错能力的图形格式来说,这似乎不是问题,但是 Office XML 格式文件会被这些额外的数据损坏。
我在打印/回显文件内容之前尝试使用 ob_clean() 和 ob_flush() [即在 php 中],但就 Office 而言仍然损坏。
我知道这是一个旧线程,但我将不胜感激自上次更新以来任何人可能找到的解决方案。
I have used xvi32 (a hex editor) to compare local originals of files with versions dowloaded from BLOB/LONGBLOB fields. It seems that extra bytes, which I think represent a CRLF are appended, as far as I can work out by Windows when the file is written. This doesn't seem to be a problem for some graphic formats which are to some extent fault-tolerant, but the office XML format files are corrupted by this extra data.
I have tried using ob_clean() and ob_flush() [that is, in php] before printing/echoing the file contents, but still corrupted as far as Office is concerned.
I know this is an old thread but I would appreciate any solutions anyone might have found since it was last updated.
您是否尝试使用短 txt 文件而不是 .doc 并查看内容是否与您预期的不同?
Did you try with a short txt file instead of .doc and see if the contents are different than what you expected?