Try this:
<cfif isdefined("PhotoTitle") and isdefined("Photo")>
<cfset curDirectory = "c:\Photos\">
<cfif isdefined("Add") and Add is "yes">
<cfset maximumFileSize = "50000">
<CFIF Val(CGI.CONTENT_LENGTH) GT maximumFileSize>
The file you are trying to upload exceeds the maximum
allowable size of
<CFOUTPUT><B>#maximumFileSize#</B></CFOUTPUT>
(50K) bytes and cannot be uploaded to this server! Please choose a
smaller image and try again. Click here to <A HREF="javascript
nclick=window.history.go(-1);">return.</A>
<CFABORT>
</CFIF>
<cfif ISDEFINED("Photo") and Photo NEQ ''>
<CFFILE
ACTION="upload"
FILEFIELD="Photo"
DESTINATION="#curDirectory#"
NAMECONFLICT="MAKEUNIQUE"
ACCEPT="image/*"
>
<cfset Photo = #file.serverfile#>
</cfif>
<cfquery datasource="#application.datasource#"
name="whatever">
insert into Photos(Phototitle,Photo)
Values ('#Phototitle#'',<cfif ISDEFINED("Photo") and
Photo NEQ ''>'#Photo#'<cfelse>noimage.gif</cfif>
</cfquery>
</cfif>
If the image field is required you can use javascripts to
make sure they do enter an image.
<script language="JavaScript">
<!--
<!-- Hide the code from old stupid Browsers
window.onerror=null; //Error handler
function checkit(photos) {
var primary = ""
if (!document.photos.PhotoTitle.value)
{ primary = primary + " Photo Title is needed\n" }
if (!document.photos.Photo.value)
{ primary = primary + " Photo is needed\n" }
//After the commend goes through the checking...
if (primary == "") {
document.photos.submit();
}
//If the condition is not met, this happens..
else
{
alert ("Please Fillout:\n" + primary + "!!")
return false;
}
}
// -->
</script>
<form id="photos" method="post" action="whereever.cfm"
NAME="photos" OnSubmit="return checkit(); return false;"
ENCTYPE="multipart/form-data">
<table width="392" height="77" border="0" align="left"
cellpadding="1" cellspacing="1" bgcolor="#000000">
<tr>
<td valign="top" bgcolor="#FDC91D">Title:</td>
<td valign="top" bgcolor="#202020"><input
name="PhotoTitle" type="text" value="" size="35" /></td>
</tr>
<tr>
<td valign="top" bgcolor="#FDC91D">Photo:</td>
<td valign="top" bgcolor="#202020"><input
name="Photo" type="file" id="Photo" value="" size="35"
/></td>
</tr>
<tr>
<td valign="top" bgcolor="#202020"><div
align="right">
<input name="Submit3" type="submit" value="Submit" />
</div></td>
</tr>
</table>
</form>
Try it; I hope it works for you.