| 
	
 | 
 Posted by Rik Wasmus on 10/18/07 17:33 
On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus   
<luiheidsgoeroe@hotmail.com> wrote: 
 
> On Thu, 18 Oct 2007 18:36:59 +0200, <electric_r@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 ? 
> 
> 
> 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
 
  
Navigation:
[Reply to this message] 
 |