参考示例:FileUpload:文件上传控件
创建FileUpload
<input id="fileupload1" class="mini-fileupload" name="Fdata" limitType="*.txt"
flashUrl="swfupload/swfupload.swf"
uploadUrl="upload.aspx"
onuploadsuccess="onUploadSuccess"
/>
服务端处理
// 获得程序路径
string tempFile = Request.PhysicalApplicationPath;
//找到目标文件对象
HttpPostedFile uploadFile = Request.Files["Fdata"];
// 如果有文件, 则保存到一个地址
if (uploadFile.ContentLength > 0)
{
uploadFile.SaveAs(string.Format("{0}{1}{2}", tempFile, "demo\\fileUpload\\upload\\", uploadFile.FileName));
}
Response.Write(uploadFile.FileName +"("+DateTime.Now+")"); //可以返回一个JSON字符串, 在客户端做更多处理