General Car Related Discussion. To discuss anything that is related to cars and automotive technology that doesnt naturally fit into another forum catagory.

Anyone good with PHP? Quick question!

Thread Tools
 
Search this Thread
 
Old Feb 13, 2005 | 04:31 PM
  #1  
Phil's Avatar
Phil
Thread Starter
Jeebus
iTrader: (1)
 
Joined: May 2003
Posts: 8,663
Likes: 0
From: Staffordshire, UK
Default Anyone good with PHP? Quick question!

I have this code as part of a system inserting an image into a database:

$ffile = fopen($_FILES['image']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
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:

if ($image!="")
{
$ffile = fopen($_FILES['image']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['image']['size']);
$eimage = mysql_escape_string($contents);
}
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!
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
markk
Ford RS Cosworth Parts for Sale
7
Dec 2, 2021 06:59 PM
Anutternutter
Ford Sierra/Sapphire/RS500 Cosworth
24
Aug 31, 2015 01:24 PM
Gadget
Ford Escort RS Cosworth
1
Aug 13, 2015 06:43 AM
Ben26
Restorations, Rebuilds & Projects.
3
Aug 11, 2015 04:19 PM
liam-rst
General Car Related Discussion.
6
Aug 10, 2015 08:46 AM




All times are GMT. The time now is 03:08 AM.