Re: MySQL Insert via SQL?

From: Date: Thu, 08 Jan 2004 02:40:46 +0000
Subject: Re: MySQL Insert via SQL?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-32324@lists.php.net to get a copy of this message
hi! just a question: don't know it exactly: isn't it possible that the sql-user on the server may not have enough rights to read the file? anyway, i would save the file elsewhere on the server, because there are remarkable performance-issues with big data (tried it once with storing images for a photo-gallery). it is much faster saving the file in some directory and just save the path to the file in the db; which on the other hand, can lead to synchronisation-problems. what do you think about this topic? thx -ma # life would be easier if i knew the source code... > Von: "John W. Holmes" <holmes072000@charter.net> > Antworten an: holmes072000@charter.net > Datum: Wed, 07 Jan 2004 21:29:20 -0500 > An: Will W <will.w@reptilians.org> > Cc: PHP DB <php-db@lists.php.net> > Betreff: Re: [PHP-DB] MySQL Insert > > Will W wrote: > >> Can anyone tell me how to insert a file, >> say a .doc, .txt or a .rtf file into a table from an upload form?? > > How about just this: > > $query = "INSERT INTO Table (orig_name, size, mime_type, data) VALUES > ('{$_FILES['userfile']['name']}', > '{$_FILES['userfile']['size']}', > > '{$_FILES['userfile']['type']}',LOAD_FILE('{$_FILES['userfile']['tmp_name']}') > )"; > > Adapt to your needs. No need for PHP to read the file when you can just > let MySQL do it. :) > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals ­ www.phparch.com > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.db (#32324) next »