note 35629 added to features.file-upload
| From: | heivio at hotmail dot com | Date: | Tue, 09 Sep 2003 04:37:57 +0000 |
| Subject: | note 35629 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55870@lists.php.net to get a copy of this message | ||
To upload huge file to any BLOB to mySQL database, there is a simplest solution with only one
special requirement. You must have the right to use command
{LOAD_FILE("<FilePathname>")}. <FilePathname> must be composed with
'/' (forward slashes) or you may use 'str_replace(str,str,str)' to replace the
backward ('\') slashes for windows platform.
e.g.
C:\WINDOWS\TEMP\php2064.TMP (pathname backward slashes)
C:/WINDOWS/TEMP/php2064.TMP (pathname with forward slashes)
Example:
(Assume you have asscess right to "LOAD_FILE()" in mySQL)
<?php
//establish database connection using user defined class.
$db = new dbConnection();
$link = $db->connect();
$fileName = $_FILES['image']['tmp_name'];
$imgLocation = str_replace("\\","/", $fileName);
/* '\\' represent '\' */
echo $imgLocation;
$rval['update'] = mysql_query("UPDATE Users
SET photo = LOAD_FILE(\"$imgLocation\")
WHERE userid = 'foo' ",$link)
or
die (mysql_error($link));
//commit is used , just in case.
$commit = mysql_query('commit');
mysql_close($link);
?>
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35629
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35629&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35629&report=yes