Re: MySQL Insert
| From: | John W. Holmes | Date: | Thu, 08 Jan 2004 02:29:20 +0000 |
| Subject: | Re: MySQL Insert | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32323@lists.php.net to get a copy of this message | ||
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