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

New Topic/Question
Reply




MultiQuote





|