在文本字段中插入文本文件 [英] Insert text file in a text field

查看:105
本文介绍了在文本字段中插入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<> Hallo,


我有两个问题:


使用php和mysql:


1)如何将文本文件插入表格的TEXT字段?


2)如何将Microsoft Word文件插入到
的BLOB字段中
桌子?


请你帮我一个简单的例子吗?


谢谢。


Fab

解决方案

2007年10月18日星期四18:36:59 +0200,< el * *******@yahoo.itwrote:


你好,


我有2个问题:


使用php和mysql:


1)如何将文本文件插入表格的TEXT字段?


2)如何将微软Word文件插入

表的BLOB字段?


请你帮我一下一个简单的例子?



mysql_query(" INSERT INTO tablename(fieldname)VALUES

(''" .mysql_real_escape_string(file_get_contents(''/ path / to / file''))。"'')");

-

Rik Wasmus


< blockquote> On Thu,2007年10月18日19:29:54 +0200,Rik Wasmus

< lu ************ @ hotmail.comwrote:


On Thu,2007年10月18日18:36:59 +0200,< el ******** @ yahoo.itwrote:


> Hallo,

我有两个问题:

用php和mysql:

1)怎么能我将一个文本文件插入到表的TEXT字段中?

2)如何将一个Microsoft Word文件插入到
表的BLOB字段中?
拜托,你能帮我一个简单的例子吗?




mysql_query(" INSERT INTO tablename(fieldname)VALUES

(''" .mysql_real_escape_string(file_get_contents(' /path/to/file''))."'')");



Hmmm,

或:mysql_query(" INSERT INTO tablename(fieldname)VALUES

(LOAD_FILE( ''/ path / to / file''))");


为此,你必须确保:

- 数据库与文件在同一主机上

- 你有FILE权限

- 文件可读

- 文件大小小于max_allowed_pa​​cket字节


-

Rik Wasmus


10月18日下午6:36,电子... @ yahoo.it写道:


你好,


我有2个问题:


使用php和mysql:


1)如何将文本文件插入表格的TEXT字段?


2)如何将微软word文件插入到

表的BLOB字段中?


请你帮我一个简单的例子?


谢谢。


Fab



我写了一个关于将文件上传到mysql数据库的教程。

你可以在这里阅读: http://wiki.greenquery.com/doku.php?

id = understanding_php_classes#creating_uploadhandle r


我希望这对你有所帮助。


// Michael


Hallo,

I have 2 questions:

with php and mysql :

1) How can I insert a text file into a TEXT field of a table ?

2) How can I insert a microsoft word file into a BLOB field of a
table ?

Please, could you help me with a simple example ?

Thank you .

Fab

解决方案

On Thu, 18 Oct 2007 18:36:59 +0200, <el********@yahoo.itwrote:

Hallo,

I have 2 questions:

with php and mysql :

1) How can I insert a text file into a TEXT field of a table ?

2) How can I insert a microsoft word file into a BLOB field of a
table ?

Please, could you help me with a simple example ?


mysql_query("INSERT INTO tablename (fieldname) VALUES
(''".mysql_real_escape_string(file_get_contents(''/path/to/file''))."'')");
--
Rik Wasmus


On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus
<lu************@hotmail.comwrote:

On Thu, 18 Oct 2007 18:36:59 +0200, <el********@yahoo.itwrote:

>Hallo,

I have 2 questions:

with php and mysql :

1) How can I insert a text file into a TEXT field of a table ?

2) How can I insert a microsoft word file into a BLOB field of a
table ?

Please, could you help me with a simple example ?



mysql_query("INSERT INTO tablename (fieldname) VALUES
(''".mysql_real_escape_string(file_get_contents(''/path/to/file''))."'')");

Hmmm,
or: mysql_query("INSERT INTO tablename (fieldname) VALUES
(LOAD_FILE(''/path/to/file''))");

For this you''d have to make sure:
- the database is on the same host as the file
- you have the FILE privilege
- the file is readable
- the filesize is less than max_allowed_packet bytes

--
Rik Wasmus


On Oct 18, 6:36 pm, electri...@yahoo.it wrote:

Hallo,

I have 2 questions:

with php and mysql :

1) How can I insert a text file into a TEXT field of a table ?

2) How can I insert a microsoft word file into a BLOB field of a
table ?

Please, could you help me with a simple example ?

Thank you .

Fab

I wrote a tutorial on uploading files into a mysql database.
You can read it here :http://wiki.greenquery.com/doku.php?
id=understanding_php_classes#creating_uploadhandle r

I hope it''s for some help to you.

//Michael


这篇关于在文本字段中插入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆