Uploading files like gmail

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

62 Replies - 13811 Views - Last Post: 28 July 2009 - 01:12 PM Rate Topic: -----

#1 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Uploading files like gmail

Posted 08 August 2008 - 12:57 PM

Hey Everyone,

Well i am hoping someone can help me understand what i am doing wrong with this because i cant figure it out.

Well what i am trying to do is similar to gmail's attachments. where you can upload multiple attachments. I found some of a script on how to do this here. http://www.easycfm.c...amp;Topic=13543.

However, i can not seem to get it to work on mine. What happens is it will insert multiple records into my database, but where the file goes it inserts the same file instead of 2 different files. Like if i insert file1.txt and file2.txt in both places it will say file1.txt. However, where my files are suppose to be stored you will see file1.txt and file2.txt.

heres the form
<form action="userform.cfm" id="userForm"  name="userForm" method="POST" enctype="multipart/form-data"> <input type="file" name="attachment1" id="attachment" value="#attachment_ID_counter#" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
		  <div id="moreUploads"></div>
		  <div id="moreUploadsLink" style="display:none;">
		  <input type="button" value="Attach another file" 
   onclick="java script:addFileInput();" >
		  </div>
		  <input type="hidden" id="totalAttachments" name="totalAttachments" value="1">
<input type="submit" class="officalsubmit" value="submit" name="submit" onclick="return validate_form();">
</form>


heres my action page
<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment"& counter)>
		   try and upload it ...
		  <cffile action="upload" fileField="attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
			  <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
   '#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#Form.attachment1#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>


an i also wanted to ask. when i upload my files how would i give it a different name. Like everytime i upload it the name would be like attachmentname_id_countofattachment. an each time i upload it gets a different id and different count.

Thank you,
Rach

Is This A Good Question/Topic? 0
  • +

Replies To: Uploading files like gmail

#2 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 08 August 2008 - 12:57 PM

Hey Everyone,

Well i am hoping someone can help me understand what i am doing wrong with this because i cant figure it out.

Well what i am trying to do is similar to gmail's attachments. where you can upload multiple attachments. I found some of a script on how to do this here. http://www.easycfm.c...amp;Topic=13543.

However, i can not seem to get it to work on mine. What happens is it will insert multiple records into my database, but where the file goes it inserts the same file instead of 2 different files. Like if i insert file1.txt and file2.txt in both places it will say file1.txt. However, where my files are suppose to be stored you will see file1.txt and file2.txt.

heres the form
<form action="userform.cfm" id="userForm"  name="userForm" method="POST" enctype="multipart/form-data"> <input type="file" name="attachment1" id="attachment" value="#attachment_ID_counter#" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
		  <div id="moreUploads"></div>
		  <div id="moreUploadsLink" style="display:none;">
		  <input type="button" value="Attach another file" 
   onclick="java script:addFileInput();" >
		  </div>
		  <input type="hidden" id="totalAttachments" name="totalAttachments" value="1">
<input type="submit" class="officalsubmit" value="submit" name="submit" onclick="return validate_form();">
</form>


heres my action page
<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment"& counter)>
		   try and upload it ...
		  <cffile action="upload" fileField="attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
			  <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
   '#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#Form.attachment1#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>


an i also wanted to ask. when i upload my files how would i give it a different name. Like every time i upload it the name would be like attachmentname_id_countofattachment. an each time i upload it gets a different id and different count.

Thank you,
Rach
Was This Post Helpful? 0
  • +
  • -

#3 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,059
  • Joined: 04-January 08

Re: Uploading files like gmail

Posted 08 August 2008 - 01:48 PM

Please do not double post your questions.


thank you!
Was This Post Helpful? 0
  • +
  • -

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Uploading files like gmail

Posted 09 August 2008 - 07:52 AM

Please don't create duplicate topics.
Topics Merged.
Was This Post Helpful? 0
  • +
  • -

#5 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 11 August 2008 - 06:06 AM

View Postborn2c0de, on 9 Aug, 2008 - 07:52 AM, said:

Please don't create duplicate topics.
Topics Merged.

i didn't mean to post the question twice. was having loading problems an it accidental posted twice.
Was This Post Helpful? 0
  • +
  • -

#6 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Uploading files like gmail

Posted 11 August 2008 - 01:31 PM

View Postbonneylake, on 8 Aug, 2008 - 12:57 PM, said:

but where the file goes it inserts the same file instead of 2 different files. Like if i insert file1.txt and file2.txt in both places it will say file1.txt. However, where my files are suppose to be stored you will see file1.txt and file2.txt.
...

when i upload my files how would i give it a different name.


That is because the code is using the same field name '#Form.attachment1#' every time. The form field name should be dynamic. Based on the #counter# variable.

To rename the file try specifying the desired file name as part of the "destination" value. Another option is to "upload" then "rename" the file. Of course if a file by that name already exists, it will get renamed anyway because you are using nameconflict="MAKEUNIQUE".

But why are you using cfquery to execute a stored procedure instead of cfstoredproc?

This post has been edited by sansclue: 11 August 2008 - 01:32 PM

Was This Post Helpful? 0
  • +
  • -

#7 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 12 August 2008 - 01:43 PM

Hey Sansclue,

Nice to hear from you again :) .Today figured out the counter part. An also figured out how to get the file name for each file i upload. But i am still baffled by the renaming of files.

here is my new code for the action page (everything else above is the same)
<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment"& counter)>
		   try and upload it ...
		  <cffile action="upload" fileField="attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
		  <CFSET UPLOAD_FILE=#file.serverfile#>
			  <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
'#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#UPLOAD_FILE#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>



the first problem i am having is with the cfquery. If i have #UPLOAD_FILE# in my cfquery it will put the filename, but it wont insert multiple files (only one). If i put #counter# in the cfquery (where currently in the code #upload_file# is) it will insert multiple files but not put the filename for each file uploaded. An i don't know how to combine/ make those work together.

An well the second part i am having problems on is with the rename. The one thing i am having problems with it right now is, i don't know what file the person will be uploading until it is uploaded. Which means it could be a text file, word file, picture, anything. Like in this example (which i am uploading first and then a reloading). They know the name of there source file an i don't.

<CFFILE ACTION="Rename" 
	SOURCE="c:\files\memo\keymemo.doc" 
	DESTINATION="c:\files\memo\oldmemo.doc">


I have looked at lots of example online, but i cant seem to find one that helps me understand how to upload a file without knowing what the name of it will be.

Then the last problem i am having is when i rename it,it needs to be named something like this attach(name of attachment)_ID(gets id from cfquery form.ID)_count(count of attachment like if you upload 2 files first file will have 1 other file will have 2).But i am baffled on how to begin this as well.


If you have any suggestions on how i could fix these few problems i would really appreciate it.Sorry if this is confusing, hard to explain this problem after having to look at it for days. Ff need better explanation just ask an all try to explain it better.

Thank you again Sansclue for all your help :),
Rach
Was This Post Helpful? 0
  • +
  • -

#8 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Uploading files like gmail

Posted 13 August 2008 - 10:03 AM

Hi again,

Quote

attach(name of attachment)_ID(gets id from cfquery form.ID)_count(count of attachment like if you upload 2 files first file will have 1 other file will have 2).But i am baffled on how to begin this as well.


I don't really understand the problems you are having with the cfquery. But my suggestion would be to address the problems one at a time. It is much more difficult to debug multiple code problems at the same time. So comment out the cfquery for now and focus on the file uploading. Once that portion is working, move on to the query. Though you should be using cfstoredproc, not cfquery. Unless there is a good reason for it..

After you have uploaded a file inside your loop, you can access information about the saved file using the CFFILE structure. If you review the documentation, it has a complete list the values available.

http://livedocs.adob...cs/00000253.htm
CFFILE.serverDirectory - Directory of the file saved on the server
CFFILE.File - Filename of the file saved on the server
CFFILE.FileName - Filename of the file saved on the server (without an extension)
CFFILE.FileExt - Extension of the uploaded file on the server (without a period)
...

You can easily use those values to construct the "old" and "new" file names. Note, I am assuming (name of attachment) is the name of the file, without the extension:

<cfloop ...>
<cffile action="upload" ...>

<cfset oldFileName = CFFILE.File>
<cfset newFileName = CFFILE.FileName &"_"& form.ID &"_"& counter>
<cffile action="rename" ....>
....

</cfloop>

You should also add some debugging code inside your loop. So you can see what is actually happening inside the loop.
Was This Post Helpful? 0
  • +
  • -

#9 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 13 August 2008 - 11:01 AM

Hey Sansclue,

Well i think i got "most" of the cfquery figured out. The problem was either i could upload multiple files an not have the files name (instead it puts whats in the files into the database an not the file name) or i could have the name of the file, but it would only upload one file.

Anyway i took the word "count" out of all of this an that has allowed me to upload multiple files. But now i am stuck on this. When i try to upload 2 files, for the first file it will put the file name, but for the second file it puts i guess i would call it a unique name for it like ACF39DD.TXT An it does this even though the files are 2 different names (the files i am using to test this is test1.txt and test2.txt). But here is the code with what i changed. If you got any suggestions on how i could fix this part it would very appreciated. It seems simple, but for some reason i just can't piece it together.

<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="attachment">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment")>
		   try and upload it ...
		  <cffile action="upload" fileField="attachment" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
			  <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
'#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#cffile.serverfile#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>


an i am trying to not really focus on the rename part cause like you said its a lot to think about. Just hard to because seem so closely related. But this is what i had tried for the rename. i put this right under the cffile upload (its not in the code above because trying to focus on the uploading itself).
But like i said not sure what to put in the destination. I tried to put just do a basic name like test behind it but it didn't even put the file in there. But i am going to try your idea after i get past the uploading part, but just thought i would show you what i have tried.

<CFFILE ACTION="RENAME" SOURCE="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\#CFFILE.ServerFile#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\>


but if you got any suggestions on how i could handle the cfquery part of this it be much appreciate because i know its probably something simple, an i am just missing it.

But thank you again for all your help Sansclue :)
Rach
Was This Post Helpful? 0
  • +
  • -

#10 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Uploading files like gmail

Posted 13 August 2008 - 11:41 AM

View Postbonneylake, on 13 Aug, 2008 - 11:01 AM, said:

When i try to upload 2 files, for the first file it will put the file name, but for the second file it puts i guess i would call it a unique name for it like ACF39DD.TXT An it does this even though the files are 2 different names (the files i am using to test this is test1.txt and test2.txt).


The files having different names doesn't matter. What matters is the whether the destination directory already contains a file by that same name. You cannot have two files with the same name in the same directory. So if you upload 'myFile.txt' to the same directory twice, CF will create a unique name for the second file. ie if you have been testing repeatedly with the same 5-6 files, chances are the destination directory already contains files with those names from previous attempts. Make sense?

If CF is generating names like 'ACF39DD.TXT' you must be using an older version. IIRC CF8 generates more user friendly names like: myFile1.txt, myFile2.txt, myFile3.txt .... etc. You could try using the CFFILE.Clientxxxx variables. In theory they should contain the original names of the files. Though I have never used them much.

This post has been edited by sansclue: 13 August 2008 - 11:44 AM

Was This Post Helpful? 0
  • +
  • -

#11 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 13 August 2008 - 02:52 PM

Hey Sansclue,

Everything you say makes since, but still didn't work. I went an deleted all the files an instead of giving me test1.txt and test2.txt when i went to try an reupload it,it went an rewrote both files like i described to you with ACF39DD.TXT (but both different names of course). But although you say everytime i add a file that has the same name it should give a unique name,which your right it should be that way, but for some reason that is not the case. Everytime i uploaded just test1.txt (uploaded 1 file) it uploaded it with no problem an never was rewritten because i seen it in my table many times testing with the code above. But when i tried to upload 2 files at the same time it would keep the name for the first file uploaded but for the 2nd file uploaded it changed the name.

So i don't know what that tells me but it really don't make since. If you have any other suggestions it would be very much appreciated.

But thank you for all the help you have given me,
Rach
Was This Post Helpful? 0
  • +
  • -

#12 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Uploading files like gmail

Posted 13 August 2008 - 03:47 PM

View Postbonneylake, on 13 Aug, 2008 - 02:52 PM, said:

Hey Sansclue,

Everything you say makes since, but still didn't work. I went an deleted all the files an instead of giving me test1.txt and test2.txt when i went to try an reupload it,it went an rewrote both files like i described to you with ACF39DD.TXT (but both different names of course). But although you say everytime i add a file that has the same name it should give a unique name,which your right it should be that way, but for some reason that is not the case. Everytime i uploaded just test1.txt (uploaded 1 file) it uploaded it with no problem an never was rewritten because i seen it in my table many times testing with the code above. But when i tried to upload 2 files at the same time it would keep the name for the first file uploaded but for the 2nd file uploaded it changed the name.

So i don't know what that tells me but it really don't make since. If you have any other suggestions it would be very much appreciated.

But thank you for all the help you have given me,
Rach


I hear what you are saying, but that is next to impossible if you are uploading to the same directory and using "makeunique" ;-)

Are you actually checking at the physical files on the file system ... or are you basing this off of information in your database table?
Was This Post Helpful? 0
  • +
  • -

#13 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 13 August 2008 - 07:48 PM

Hey Sansclue,

Yeah it is suppose to be impossible but for some reason i have made it possible, somehow.

But i been checking both where the files are going an the database. Right now the way i have the code with the counter out of it. It is uploading 2 files to the database, an if you go to the files you will see 2 files. It is just not putting the name of the file in the database an instead is renaming the files i upload. I don't know if taking makeunique out of it would solve this problem or not?

its funny when i was uploading the files, before i deleted all the million copys of test1.txt, everytime i uploaded test1.txt, it would give it the correct name of test1.txt but if i tried to upload a second one with it then it would rename the second one. But then after i took out all the test1.txt now it renames the first file i upload an the 2nd file i upload. Starting to think that i should go back to the code i had before with the counter. The only problem i had with it was uploading multiple files, would upload first file an give correct file name but wouldn't upload any more files. Here is the code i had before i took out counter because i know i have posted a lot of different versions of this code

<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment"& counter)>
		   try and upload it ...
		  <cffile action="upload" fileField="form.attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
 <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
'#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#cffile.serverfile#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>


Right now with the above code it doesn't upload multiple files an well how i understand it is the cfloop is suppose to allow me to loop through an upload multiple files and by having cffile.serverfile in the cfquery it is suppose to allow me to put the file name in the database. An well before i put cffile.serverfile in the cfquery it was uploading multiple files but it just wasent putting the field names, it was instead putting what is inside both of the files into the database. So i am thinking maybe the way i have the cfloop is causing the problem? just a guess because i am just confused on it. But if there was a way i could put #cffile.serverfile# and #counter# together in the cfquery i would be good, but cant seem to get that.

if you got any other suggestions on what i could try let me know.

Thank you again for all your help :D ,
Rach
Was This Post Helpful? 0
  • +
  • -

#14 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Uploading files like gmail

Posted 14 August 2008 - 05:50 AM

Hey,

Something is just not right here, but it is hard to tell what. I am still skeptical about the unique name part, because I have never heard of that happening ;-)

Try taking the query out of the picture and running some debugging code. Clear out the directory. Then upload files "test1.txt" and "test2.txt" twice. Then post the results here. Just insert the correct path in the #destDirectory# variable.

<cfoutput>
<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset destDirectory = ExpandPath("..\uploaded\")>
	 <!--- verify directory exists ---->
	 Does directory exist? = #DirectoryExists(destDirectory)#<br>
	 <cfif DirectoryExists(destDirectory)>
		<!--- show contents of this directory --->
		<cfdirectory action="list" directory="#destDirectory#" name="dirContents">
		<cfdump var="#dirContents#" label="Directory Contents BEFORE upload">
	 <cfelse>
	 	<cfabort showerror="The destination directory does not exist: #destDirectory#">
	 </cfif>
	
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
		  Processing attachment [#counter#]...<br>
	 	<cfif structKeyExists(FORM, "attachment"& counter)>
		   <cfoutput>
		   Uploading attachment [#counter#] ...<br>
		   </cfoutput>
		  <cffile action="upload" 
				fileField="form.attachment#counter#" 
				destination="#destDirectory#" 
				nameconflict="MAKEUNIQUE">
		  <cfdump var="#cffile#" label="Attachment #counter# details">		
		  <table>
		  <tr><th>FileWasSaved</th>
				<th>FileExisted</th> 
				<th>FileWasOverwritten</th>
				<th>Client File</th>
				<th>Server File</th>
				<th>Server Directory</th>
		  </tr>	
		  <tr><td>#CFFILE.FileWasSaved#</td>
			  <td>#CFFILE.FileExisted#</td>
			  <td>#CFFILE.FileWasOverwritten#</td>
			  <td>#CFFILE.ClientFile#</td>
			  <td>#CFFILE.ServerFile#</td>
			  <td>#CFFILE.ServerDirectory#</td>
		  </tr>	
		  </table>
		</cfif>
	</cfloop>
</cfif>
</cfoutput>


Was This Post Helpful? 0
  • +
  • -

#15 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Uploading files like gmail

Posted 14 August 2008 - 06:28 AM

Hey Sansclue,

All i can say is i am an idiot. After much stress i realized that the reason it was not uploading right was because of the html. In the html i changed the name from name="attachment" when it needed to be name="attachment1". An now the make unique works right now. I uploaded 2 files an the first time i did this is uploaded test1.txt and test2.txt an then when i went to upload 2 files again(same files) it gave them a unique name so now all that is working.

Heres the html
 <input type="file" name="attachment1" id="attachment" value="#attachment_ID_counter#" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
		  <div id="moreUploads"></div>
		  <div id="moreUploadsLink" style="display:none;">
		  <input type="button" value="Attach another file" 
   onclick="java script:addFileInput();" >
		  </div>
		  <input type="hidden" id="totalAttachments" name="totalAttachments" value="1">


heres the cfquery
<cfif structKeyExists(FORM, "totalAttachments")>
	 <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
	 <cfparam name="FORM.totalAttachments" default="0">
	 <cfloop from="1" to="#form.totalAttachments#" index="counter">
	  verify the form field exists 
	 <cfif structKeyExists(FORM, "attachment"& counter)>
		   try and upload it ...
		  <cffile action="upload" fileField="form.attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
			  <cfquery name="attachment" datasource="CustomerSupport">
	exec usp_CS_Insertattachments
'#Form.ID#','#evaluate(serialnum)#','#Form.attachdescrip#','#cffile.serverfile#','#Form.fk_addedBy#','#Form.date_added#'
</cfquery>
	 </cfif>
	 </cfloop>
</cfif>


but if you wouldn't mind putting up with me a little bit more could you explain how i could do the rename part of this?i have looked at examples online but i am still baffled on how to do this the way i am trying to accomplish this.

here is what i got right now for the rename an was going to put this under the cffile upload.
<CFFILE ACTION="RENAME" SOURCE="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\#CFFILE.ServerFile#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\">


but thank you so much for all the help you have given me :D ,
Rach
Was This Post Helpful? 0
  • +
  • -

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »