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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
phpDVWeaver
Forum Commoner
Posts: 28
Joined: Sun Apr 29, 2007 11:00 pm

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

Post by phpDVWeaver »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


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

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';
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

"Databases" is the wrong forum for this question.

Where is $figpath set and what does

Code: Select all

if (isset($figpath)) {
  echo '<div>Debug: '; var_dump($figpath); echo '</div>';
  $figImage=addslashes(fread(fopen($figpath,"r"),filesize($figpath)));
print?
phpDVWeaver
Forum Commoner
Posts: 28
Joined: Sun Apr 29, 2007 11:00 pm

Post by phpDVWeaver »

$figpath is the php variable that hold the upload (submit input with the name figpath and value upload).
Post Reply