Page 1 of 1

Warning: fread(): supplied argument is not a valid stream

Posted: Mon May 21, 2007 9:58 am
by phpDVWeaver
am trying to upload images in MySql using php. whenever I run the following code I get this message:

Warning: fread(): supplied argument is not a valid stream resource in C:\webs\test\CNST Projects\Genaral Upload Form\figUpload.php on line 6

config.php is where I assign the database, the user, and the password.
openDB.php is where the database is opened
closeDB.php is where the database is closed
$figpath is the php variable that holds the path of the figure to upload (it's an input wher the type is file and the name is figurepath )
php:

Code: Select all

<?php 
include'phpFigures/config.php'; 
include'phpFigures/openDB.php'; 
include'phpFigures/assignValues.php'; 
if (isset($figpath)){ 
$figImage=addslashes(fread(fopen($figpath,"r"),filesize($figpath))); 
$query = "INSERT INTO images(description, image) VALUES ('$figdescription', '$figImage')"; 
mysql_query($query) or die("Query failed: " . mysql_error()); 
echo "The figure is successfully Uploaded!"; 
} 
else{ 
echo "You did not Upload any figure!"; 
} 
include'phpFigures/closeDB.php';

Posted: Mon May 21, 2007 10:51 am
by thiscatis
We have a very special forum for php related issues and this ain't it.

Posted: Mon May 21, 2007 10:54 am
by RobertGonzalez
Moved :arrow: PHP -Code.