Hi I am hoping someone here can help me. I am trying to create an insert property page for our real estate website. I am using CF and MSaccess.
I am currently using the following code:
<cfif isdefined("form.submit_upload")>
<cffile action="UPLOAD" filefield="filename1" destination="directpath" nameconflict="MAKEUNIQUE">
<CFSET img1= AgentLOGIN& DateFormat(Now(),"DDMMYY") & TimeFormat(Now(),"HHmmss")>
<CFSET img=ListAppend(img1,FILE.ServerFileExt,".")>
<CFFILE ACTION="RENAME" SOURCE="directpath\#CFFILE.ServerFile#" destination="directpath\#img#">
<cfset form.filename1="#img#">
</cfif>
This is put at the top of the page before the cfinsert code which inserts the details from the form into the db including the name of the file. This works absolutly fine, uploads the image and renames it and then inserts the name into the db.
The problem is I want to allow 3 files to be uploaded at the same time. I have tried just simply duplicating the code with a few changes to names and such .ie #img# is changed to #img2# but it does'nt seem to work. I end up with the first file inserted into the db ok but the file is not renamed and the second file is uploaded and renamed but the coldfusion temporary path is inserted into the db rather than the filename. I am sure I am missing something really simple here or is there an easier way to do this. I have read tons and tons of posts on this subject but can't seem to apply any of the practices to my own application. Any help with this would be most appreciated.
Rob
I am currently using the following code:
<cfif isdefined("form.submit_upload")>
<cffile action="UPLOAD" filefield="filename1" destination="directpath" nameconflict="MAKEUNIQUE">
<CFSET img1= AgentLOGIN& DateFormat(Now(),"DDMMYY") & TimeFormat(Now(),"HHmmss")>
<CFSET img=ListAppend(img1,FILE.ServerFileExt,".")>
<CFFILE ACTION="RENAME" SOURCE="directpath\#CFFILE.ServerFile#" destination="directpath\#img#">
<cfset form.filename1="#img#">
</cfif>
This is put at the top of the page before the cfinsert code which inserts the details from the form into the db including the name of the file. This works absolutly fine, uploads the image and renames it and then inserts the name into the db.
The problem is I want to allow 3 files to be uploaded at the same time. I have tried just simply duplicating the code with a few changes to names and such .ie #img# is changed to #img2# but it does'nt seem to work. I end up with the first file inserted into the db ok but the file is not renamed and the second file is uploaded and renamed but the coldfusion temporary path is inserted into the db rather than the filename. I am sure I am missing something really simple here or is there an easier way to do this. I have read tons and tons of posts on this subject but can't seem to apply any of the practices to my own application. Any help with this would be most appreciated.
Rob