Hi guys,
for using file uploading control in your site just pick up this code and try to find out the solution.
It's work in a nice way.
Thank's.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ColdFusion And AJAX File Upload Demo</title>
<!-- Linked scripts. -->
<script type="text/javascript" src="jquery-1.2.2.pack.js"></script>
<script type="text/javascript" src="ajax_upload.js"></script>
<script>
$(
function(){
var jForm = $( "form:first" );
jForm.submit(
function( objEvent ){
var jThis = $( this );
var strName = ("uploader" + (new Date()).getTime());
var jFrame = $( "<iframe name=\"" + strName + "\" src=\"about:blank\" />" );
jFrame.css( "display", "none" );
jFrame.load(
function( objEvent ){
var objUploadBody = window.frames[ strName ].document.getElementsByTagName( "body" )[ 0 ];
var jBody = $( objUploadBody );
var objData = eval( "(" + jBody.html() + ")" );
prompt( "Return Data:", objData );
setTimeout(
function(){
jFrame.remove();
},
100
);
}
);
$( "body:first" ).append( jFrame );
jThis
.attr( "action", "upload_act.cfm" )
.attr( "method", "post" )
.attr( "enctype", "multipart/form-data" )
.attr( "encoding", "multipart/form-data" )
.attr( "target", strName )
;
}
);
}
);
<cfset arrFiles = [] />
<cfloop
index="strFileIndex"
from="1"
to="10"
step="1">
<cfset strField = "upload#strFileIndex#" />
<cfif (
StructKeyExists( FORM, strField ) AND
Len( FORM[ strField ] )
)>
<!--- Upload file. --->
<cffile
action="upload"
filefield="#strField#"
destination="#ExpandPath( '~/resume/' )#"
nameconflict="makeunique"
/>
<cfset ArrayAppend( arrFiles, CFFILE.ServerFile ) />
</cfif>
</cfloop>
</script>
</head>
<body>
<form>
<input type="file" name="upload1" size="60" /><br />
<br />
<input type="file" name="upload2" size="60" /><br />
<br />
<input type="submit" value="Upload Files" />
</form>
</body>
</html>
No comments:
Post a Comment