Question
Upload File: Make File Field NOT required
I have a form that submits product information to Access db
and uploads image.. That part works great. However if i do not have
an Image to upload for a product the form spits out error.
The form field "ItemImage" did not contain a file.
I want to be able assign ItemImage value as "default.gif" in the db if no file was uploaded.
Here is a look at my source. Can someone please help me with this.
The form field "ItemImage" did not contain a file.
<cfif isdefined("form.upload_now")>
<div align="center" class="style5">
<cffile action="upload" filefield="ItemImage" destination="c:\ohlWestIms\scripts\purchase-orders\images\" accept="image/jpeg, image/x-png, image/pjpeg, image/gif" nameconflict="Skip">
Item has been Added .
<cfquery datasource="dsnPurchaseOrders">
INSERT INTO Items (ItemName, ItemDiscrip, ItemPrice, ItemImage, ItemCompany, ItemNumber)
VALUES (
<cfif IsDefined("FORM.ItemName") AND #FORM.ItemName# NEQ "">
'#FORM.ItemName#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemDiscrip") AND #FORM.ItemDiscrip# NEQ "">
'#FORM.ItemDiscrip#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemPrice") AND #FORM.ItemPrice# NEQ "">
'#FORM.ItemPrice#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemImage") AND #FORM.ItemImage# NEQ "">
'#cffile.ServerFile#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemCompany") AND #FORM.ItemCompany# NEQ "">
'#FORM.ItemCompany#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemNumber") AND #FORM.ItemNumber# NEQ "">
'#FORM.ItemNumber#'
<cfelse>
NULL
</cfif>
)
</cfquery>
</div>
</cfif>
The form field "ItemImage" did not contain a file.
I want to be able assign ItemImage value as "default.gif" in the db if no file was uploaded.
Here is a look at my source. Can someone please help me with this.
The form field "ItemImage" did not contain a file.
<cfif isdefined("form.upload_now")>
<div align="center" class="style5">
<cffile action="upload" filefield="ItemImage" destination="c:\ohlWestIms\scripts\purchase-orders\images\" accept="image/jpeg, image/x-png, image/pjpeg, image/gif" nameconflict="Skip">
Item has been Added .
<cfquery datasource="dsnPurchaseOrders">
INSERT INTO Items (ItemName, ItemDiscrip, ItemPrice, ItemImage, ItemCompany, ItemNumber)
VALUES (
<cfif IsDefined("FORM.ItemName") AND #FORM.ItemName# NEQ "">
'#FORM.ItemName#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemDiscrip") AND #FORM.ItemDiscrip# NEQ "">
'#FORM.ItemDiscrip#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemPrice") AND #FORM.ItemPrice# NEQ "">
'#FORM.ItemPrice#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemImage") AND #FORM.ItemImage# NEQ "">
'#cffile.ServerFile#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemCompany") AND #FORM.ItemCompany# NEQ "">
'#FORM.ItemCompany#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.ItemNumber") AND #FORM.ItemNumber# NEQ "">
'#FORM.ItemNumber#'
<cfelse>
NULL
</cfif>
)
</cfquery>
</div>
</cfif>