Re: LOAD_FILE and PHP
| From: | Jough P | Date: | Fri, 16 Jan 2004 19:44:06 +0000 |
| Subject: | Re: LOAD_FILE and PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174868@lists.php.net to get a copy of this message | ||
Greetings all, I'm still having problems with LOAD_FILE. If anyone is using it and could post some examples that would be fabulous.
Thanks tons!!!
On Jan 16, 2004, at 9:12 AM, Jough P wrote:
Greetings all, I can't get LOAD_FILE to work in an INSERT statement from PHP. The generated sql works when you're in mysql but won't work from PHP. BSDB is my database object. sql_query basically just does a mysql_query and some error outputting stuff. There error is: Column 'photo' cannot be null My SQL statement is: INSERT INTO photo VALUES('', LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png")) The first column is an auto-increment id, the second column is the photo. Here's a code snippet: $uploaddir = '/Library/WebServer/Documents/var/tmp/'; $uploadfile = $uploaddir . $_FILES['userfile']['name']; if ($_FILES['userfile']['type'] == "image/jpeg" ||$_FILES['userfile']['type'] == "image/png" || $_FILES['userfile']['type'] == "image/gif" ){if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { print "File is valid, and was successfully uploaded. "; print "Here's some more debugging info:\n"; print "<pre>"; print_r($_FILES); print "</pre>"; echo "<IMG SRC=/var/tmp/" . $_FILES['userfile']['name'] . "><BR>"; $bsdb = new BSDB(); $sql = "INSERT INTO photo VALUES('', LOAD_FILE(\"$uploadfile\"))"; echo "$sql<BR>\n"; chmod($uploadfile,0755); $result = $bsdb->sql_query($sql); } else { print "Possible file upload attack! Here's some debugging info:\n"; print "<pre>"; print_r($_FILES); print "</pre>"; }} Thanks for your help!!