|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Optional File Upload
I'm having a problem with my file upload for a site. I want the upload field to be optional, so if the user decides not to change the image for the item they are editting, they dont' have to. What's happening is when the file form is left blank I get the error:
The form field "ImageUpload" did not contain a file. Here is the code for the changes it is to make upon the upload: <cfif isDefined("FORM.ImageUpload")> <cfoutput> <cffile action="upload" filefield="ImageUpload" destination="#getDirectoryFromPath(ExpandPath("../../products/#ImageLocation1#/"))#" accept="image/*" nameconflict="overwrite"> <CFX_IMAGE ACTION="RESIZE" FILE="#getFileFromPath(ExpandPath("../../products/#ImageLocation1#/"))##Form.ImageUpload#" OUTPUT="#getDirectoryFromPath(ExpandPath("../../products/#ImageLocation1#/"))##FORM.SKU#sml.jpg" QUALITY="100" HEIGHT="145" name="SmallSize"> <CFX_IMAGE ACTION="RESIZE" FILE="#getFileFromPath(ExpandPath("../../products/#ImageLocation1#/"))##Form.ImageUpload#" OUTPUT="#getDirectoryFromPath(ExpandPath("../../products/#ImageLocation1#/"))##FORM.SKU#mini.jpg" QUALITY="100" HEIGHT="73" name="MiniSize"> <cffile action = "rename" source = "#getFileFromPath(ExpandPath("../../products/#ImageLocation1#/"))##Form.ImageUpload#" destination = "#getDirectoryFromPath(ExpandPath("../../products/#ImageLocation1#/"))##FORM.SKU#lrg.jpg" attributes = "normal"> </cfoutput> </cfif> It's almost as if my isDefined statement isn't working properly. Any thoughts? Thanks |
|
#2
|
|||
|
|||
|
Never mind =] I added a AND FORM.ImageUpload NEQ ""> and it works fine now.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Optional File Upload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|