-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

How about this:  Wrap the CFFILE call in a CFTRY block.  Catch the
error & deal with it if necessary, otherwise the code will just work
as it should.

Best regards,
Zac Bedell

> -----Original Message-----
> From: MJS @ Four Eyes [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 15, 2001 11:24 AM
> To: CF-Talk
> Subject: Upload module
> 
> 
> Hi, 
> 
> 
> I'm trying to create a universal upload module....so that you 
> can have as
> many uploads on a form as you want and name them whatever you 
> want.....
>  
> it all works great, unless the person doesn't upload 
> something then I get
> the:
>  
> Error processing CFFILE 
> 
> No data was received in the uploaded file '\.' Saving empty 
> (zero-length)
> files is prohibitted. Please make sure you specified the 
> correct file. 
> 
> 
> 
> this is because when it check the loop and tries to upload 
> off the form
> field...the field is empty.  I cannot seem to check the value 
> of the field
> in the loop, because at that point it is still a field name, 
> not a field
> value.  The CFFile converts it into a value itself....
> 
>  
> 
> Help please...
> 
>  
> called via
>  
> <cfmodule template="Mod_Upload_File.cfm"
>   UploadFields="ProductionImage,ProductionClip"
>   Accept="image/jpeg,image/gif,image/pjpeg,image/jpg"
>   nameconflict="Overwrite"
>   
> SavePath="D:\FOUREYES\WEBDEV\foureyesweb.com\bombo\Uploads\Pro
> ductions\"
>   dbtype="odbc"
>   DSN="Bombo"
>   Table="Productions"
>   RecordID_Name="ProductionID"
>   RecordID="43">
>  
> The module is as follows: (including fusedoc!)
>  
> <!--------------- my fusedoc -----------------
> 
> 
> Point: 
> 1) mod_upload_file.cfm will then loop through attributes:uploads
> and  
>  run a CFFile Uploading to the attribute SavePath
> 
> 2) It will then run a query on a Database (DSN) and Table (table)
> on a RecordID and field Name to
>  insert/update the file name for this upload
> 
> 
> Attributes IN:  Type = is this an Insert, Update (Remeber 
> this is Mod_upload
> not Mod_delete!!!)
>     This will determine which queryis being used
>    
>     UploadFields = Array for all files to be uploaded
>         This is the form fileds that contain the files
>     sample Uploads="Image1, Image2, Clip3"
>     
>     Accept = what type of file are we allowed to accept for this
> field 
>      sample accept="image/jpeg,image/gif,image/pjpeg,image/jpg"
>     
>     nameconflict = what to do when there is a name conflict
>      accepted values = Error , Skip, Overwrite, MakeUnique
>     
>     SavePath the path for the files to be saved to
>     sample
> SavePath="D:\FOUREYES\WEBDEV\foureyesweb.com\bombo\Uploads\Pro
> ductions\"
>     
>     DBTYPE = Type of Database (ex.ODBC)
>     
>     DSN = the DB that the query should use
>     sample DSN = "Bombo"
>     
>     Table = the table the query should use
>     Table="Productions"
>     
>     RecordID_Name = the field name in the table of the 
> primary key record ID
> 
>     RecordID = the Primary key number that the query should update
>     
>      
> Output:   Nothing: this module only writes to a database
> 
> ---->
> 
> <!---- Here we set up the loop to loop through all files that 
> are uploaded
> ---->
> 
>  
> <!--- we have to set a counter so we can track the loop --->
> <cfset Counter=1> 
> 
> <cfloop index="UploadField" list="#Attributes.UploadFields#">
> 
>  <!--- Let's Upload some files / but we have to make sure 
> that there is a
> file there first !
>         this is where I have my problem....
>  --->
>  
> 
> 
> <cfoutput>
> 
>    <cffile action="UPLOAD"
>            filefield="#UploadField#"
>            destination="#attributes.SavePath#"
>            nameconflict="#attributes.nameconflict#"
>            accept="#attributes.Accept#">
>   
>    <!---- now the query ---->
>    <cfquery name="#UploadField#" datasource="#attributes.DSN#"
> dbtype="#attributes.dbtype#">
>     UPDATE #attributes.Table#
>     SET #UploadField# = '#file.serverfile#'
>     WHERE #attributes.RecordID_Name# = #attributes.RecordID#
>    </cfquery>
>  </cfif>
> </cfoutput>
>  
>  <!--- The last thing we do is update the counter --->
>  <cfset Counter=Counter + 1>
> </CFLOOP>
> 

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!

iQA/AwUBOow/lavhLS1aWPxeEQLKnACfeEDpjPcRezFvAmuEE7WgTKFK/ZAAoOG4
2Xyb4aRg7plC6ay5MOHRfWqL
=zICR
-----END PGP SIGNATURE-----

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to