Re: Uploading Image to Database

From: Date: Sun, 19 Aug 2001 01:29:33 +0000
Subject: Re: Uploading Image to Database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63323@lists.php.net to get a copy of this message
> database ... the script seems to be working, in that its not giving errors You're not asking it to give you error messages :-) > <?php > > if ($submit) { > > MYSQL_CONNECT("localhost","user","pass"); ... or die("Could not connect to database") > mysql_select_db("binary_date"); ... or die("Could not select binary_date"); > > $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); This is pretty scary... You'll have to tear this apart into several lines to get any useful error messages... $file = fopen($form_data, 'r') or die("Could not open $form_data"); $size = filesize($form_data) or die("Could not get size of $form_data"); # php.net doesn't say what fread returns in the event of a failure... # Let's assume nobody is uploading an empty file: $rawdata = fread($file, $size) or die("Could not read data from $form_data"); $data = addslashes($rawdata); > $result=MYSQL_QUERY("INSERT INTO binary_date > (description,bin_data,filename,filesize,filetype) ". > "VALUES > ('$form_description','$data','$form_data_name','$form_data_size','$form_data _type')"); or die("Query Failed"); > > $id= mysql_insert_id(); > print "<p>This file has the following Database ID: > <b>$id</b>"; Is this printing a non-zero ID?... -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#63323) next »