an upload function like "GMail" does, which is can select multiple file in one time and direct upload
the file. Just hold the "Ctrl" key and click the needed file for upload.
here I did an upload function, but it based on various reference @ internet.
<script type="text/javascript">
var upload_number = 2;
function addFileInput()
{
var d = document.createElement("div");
var file = document.createElement("input");
file.setAttribute("type", "file");
file.setAttribute("name", "attachment"+upload_number);
d.appendChild(file);
document.getElementById("moreUploads").appendChild(d);
document.getElementById("totalAttachments").value = upload_number;
upload_number++;
}
</script>
<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:\ColdFusion9\wwwroot\RegStudent\download\"
nameconflict="MAKEUNIQUE">
</cfif>
</cfloop>
</cfif>
<cfinclude template="header.cfm">
<cfif not isDefined ("form.submit_upload")>
<table align="center">
<tr>
<td>
<br>
<form action='./create.cfm?type=create' method="POST" name="frmupload" enctype="multipart/form-data">
<input type="file" name="attachment1" id="attachment" onchange="document.getElementById('moreUploadsLink').style.display = 'block';">
<div id="moreUploads"></div>
<div id="moreUploadsLink" style="display:none;"><a href="javascript:addFileInput();" style="color:#0000ad;">Attach another File</a></div>
<input type="hidden" name="totalAttachments" value="1">
<br><br>
<input type="submit" value="UPLOAD">
</form>
</td>
</tr>
</table>
<p> </p>
<div align="center">
<cfoutput><h5><font color="##FF00FF"> <a href="index.cfm">HOME </a></font></h5></cfoutput>
</div>
</cfif>
<br><br>
<cfinclude template="footer.cfm">
Any idea if I can edit my code into the one like "Gmail" does, which is just browse the file upload, use "Ctrl" key then select any file (more than one), and then upload all the selected file.
Thanks

New Topic/Question
Reply




MultiQuote







|