Anyone good with PHP? Quick question!
I have this code as part of a system inserting an image into a database:
Now, if no image file is specified and the user hits submit this code produces an error obviously.
I'd normall just stick an if statement around it like this:
But this seems to stop it from reading the image file ever - even if one is selected! What can I use in the if statement so that it works?
Tried putting NULL in as well and that don't work!
$ffile = fopen($_FILES['image']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
I'd normall just stick an if statement around it like this:
if ($image!="")
{
$ffile = fopen($_FILES['image']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
}
{
$ffile = fopen($_FILES['image']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
}
Thread
Thread Starter
Forum
Replies
Last Post
liam-rst
General Car Related Discussion.
6
Aug 10, 2015 08:46 AM



