First, using nameconflict, unless the file name in "attach1" already exists,
you will not set a "serverFile" variable. If that's the case, and "attach1"
does not already exist, you need to CFSET SavedFile1 to the value of the file
name in FORM.attach1. They way it is now, if the file name in "attach1" does
not previously exist, "SavedFile1" is empty and your javascript will fail.
Also, best practice is to scope your variables. "attach1" should be
"FORM.attach1". You don't need the #--# around variable names inside your CFIF
or CFSET tags.
Dave
> I am trying to pass name of the saved file to another page but it is
> giving filename undefined in javascript. this is my code
>
> <cfif isdefined('attach1')>
> <cfset err1="">
> <cfset err="false">
>
> <cfif #attach1# is not "">
> <CFFILE action="UPLOAD" filefield="attach1"
> destination="C:\CFusionMX\wwwroot\Topline\intranet\cpo\attachments"
> nameconflict="MakeUnique">
> <cfset SavedFile1 = #ServerFile#>
> <cfelse>
> <cfset SavedFile1 = "">
> </cfif>
> </cfif>
>
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
>
> <body>
> <form name="frm1" action="filetest.cfm" method="post"
> enctype="multipart/form-data">
> Attach1: � <input name="attach1" type="file" id="attach1"
> size="37">
>
> <input type="submit" name="Add" value="Add">
> </form>
> <cfif isdefined('err1')>
> <cfif err eq false >
> <cfoutput>#SavedFile1#</cfoutput>
> <cfset ex=GetToken(Savedfile1,2,".")>
> <cfset fi=GetToken(Savedfile1,1,".")>
> <cfoutput>#fi#</cfoutput><br>
> <cfoutput>#ex#</cfoutput>
>
> <script language="JavaScript">
>
> document.frm1.action = "addu.
> cfm?Saved='"+<cfoutput>#SavedFile1#</cfoutput>+"'";
>
> document.frm1.method = "POST";
> document.frm1.submit();
> </script>
> </cfif>
> </cfif>
> </body>
> </html>
>
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186812
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54