Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2005, 02:22 PM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem inserting blob data/uploading file - MySQL

Hello, I have a very simple routine for inserting blob data (a jpg) into a MySQL database. I have this page deployed on both my local - WINDOWS server, and my production FreeBSD UNIX server. Both of these implementations point at the same production MySQL server. Running the routine from my local server inserts the BLOB with no problems into the DB, however runing the same exact script from the production server produces the following results:

Warning: fopen(C:\test\test.jpg): failed to open stream: No such file or directory in /urs/www/users/millersh/admin/Edit.php on line 25

The strange this is how this works great on my local windows server. Obviously there is a php value or something that needs to be configured on the production (UNIX) server - I have already tried the following:

php_value magic_quotes_gpc "1" and also "On"
php_value upload_max_filesize "10M"
php_value file_uploads "1" and also "On"
php_value upload_tmp_dir "/usr/www/users/millersh/temp/" (this directory has write access on the server)

The windows server PHP info is as follows:
http://sheahome1.no-ip.com/PHPInfo

The UNIX php info is as follows:
http://www.millershea.com/php_info

PLEASE HELP!!!! I thank you kindly in advance.

 
Old February 14th, 2005, 02:39 PM
Authorized User
 
Join Date: Jan 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not trying to state the obvious, but your message states that it is trying to open c:\test\test.jpg where the Unix environment doesnt use drive letters for partitions. Without seeing the section of code from your Edit.php file, thats what it looks like to me. Is this file being submitted from a form, or called directly? This doesnt sound like a server config problem to me.
 
Old February 15th, 2005, 10:18 AM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply - I'm somewhat of a PHP newbie - so you may not be stating the obvious. Do I need to first upload the file to a temp directory on the unix server, and THEN pipe the file into the MySQL DB? The file is being submitted from a file browser control on the page and the a postback - the file comes in as one of the $HTTP_POST_VARS[] Is this not what I want to be doing here? Here is the relavant code from Edit.php:

if (IsSet($HTTP_POST_VARS["ImageUpload"])) {
        $EmployeeID=$HTTP_POST_VARS["EmployeeID"];
                //following is the var from the <input type="file">
        $file=$HTTP_POST_VARS["file"];
        $filetyp = substr($file, -3);
        if ($filetyp == 'gif' OR $filetyp == 'jpg') {
            $handle = fopen($file,'r');
            $file_content = fread($handle,filesize
                            ($file));
            fclose($handle);
            $encoded = chunk_split(base64_encode
                            ($file_content));
            $sql = "Update Employees SET Pic = '$encoded'
                            WHERE EmployeeID = '$EmployeeID";
            mysql_query($sql);
        }
        mysql_close($connection);
        exit;

The section of Edit.php that contains the file upload control is basically as follows:

<input type="file" name="file">&nbsp;&nbsp;<input type="submit" name="ImageUpload" value="Upload">

Thanks again for the help - I think you could be right here, maybe you can be certain with this additional info. Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
BLOB: file is empty after retrieving blob data thr taraprasad Pro JSP 0 May 22nd, 2008 10:02 AM
inserting BLOB into MySQL DB, carriage newline jcsnyder PHP Databases 1 September 8th, 2006 12:51 PM
problem with uploading blob data to MySQL DB kyle_shea PHP Databases 1 March 8th, 2005 06:15 PM
problem in inserting blob data to oracle selphyr JSP Basics 2 December 2nd, 2004 01:44 PM
inserting blob data into database taoufik Beginning PHP 2 November 19th, 2004 09:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.