如何将.doc文件内容插入mysql表
我需要使用 php 将 doc 文件插入 mysql 表中。
我的文件格式如下:
。
我希望将所有标题(例如 Resume
)插入到 Type
列中,并将字幕(例如Jobtitle
)插入到 title 中mysql 表中的
字段。
我有一个表格
<FORM ENCTYPE="multipart/form-data" ACTION="{$_SERVER['PHP_SELF']}" METHOD=POST>
Upload this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="submit" name=submit></FORM>
那么我怎样才能实现它呢?
I need to insert a doc file into mysql table using php.
I have the file format like :
.
I want all the titles (e.g. Resume
) be inserted into to Type
column, and subtitles (e.g.Jobtitle
) be inserted into title
field in mysql table.
I have a form
<FORM ENCTYPE="multipart/form-data" ACTION="{$_SERVER['PHP_SELF']}" METHOD=POST>
Upload this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="submit" name=submit></FORM>
So, how could I make it happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须将其保存为二进制文件。
这是一个很好的教程:
http://mirificampress.com/permalink/ saving_a_file_into_mysql
YOu have to save it as a binary.
Here a good tutorial:
http://mirificampress.com/permalink/saving_a_file_into_mysql
您有以下选择:
使用 BLOB 列类型将文件存储在数据库中。该文件然后物理驻留在数据库中。出于性能原因,如果您要存储大量文件,这可能不是最好的主意。
将文件存储在目录中,然后将文件的路径存储在数据库中。这意味着,每次执行检索时,您首先在数据库中查找路径,然后使用该路径您应该能够使用 PHP 获取文件。
在大多数情况下,第二种方法可能会提供更好的性能。
You have the following choices:
Store the file in the database using the BLOB column type. The file then physically resides in the database. For performance reasons, this is probably not the best idea if you are storing lots of files.
Store the file in a directory, then store the path to the file in your database. That means, everytime you do a retrival, you look up the path in the database first, then using that path you should be able to fetch the file using PHP.
The second method would probably offer better performance in most cases.
根据我对问题的理解,您想使用 PHP 将 .doc 文件的内容读入 MySQL 表中。
.doc 是一种专有格式,这意味着在 PHP 中阅读将异常困难。您可能想查看 COM 函数: http://www.php .net/manual/en/book.com.php
但是,这些仅在 Windows 版本的 PHP 上可用(出于显而易见的原因)。
如果您可以将 Word 文件另存为 RTF 或 TXT,您可能有更好的机会。较新版本的 word 还使用 .docx 格式,这是以开放 XML 格式保存的文档,这也更容易用 PHP 解析。
From my understanding of the question you want to read the content of the .doc files into a MySQL table using PHP.
.doc is a proprietary format which means reading in PHP is going to be exceptionally difficult. You'll probably want to look at the COM functions: http://www.php.net/manual/en/book.com.php
However, these are only available on the Windows version of PHP (for obvious reasons).
If you can save the Word files as RTF or TXT you may have a better chance. Newer versions of word also use the .docx format which is the document saved in an open XML format, which again will be easier to parse with PHP.