您的位置:首页 > 其它

Flex多文件上传简单示例(服务端.net)

2012-09-01 21:44 393 查看
利用Flex的FileReference类和FileReferenceList类实现,首先要brow方法选择文件,load方法装载数据(切记),否在会出现IO错误,因为filereference实例的data属性null,没有引用到选择的文件,最后调用upload即可实现上传。

客户端:

逻辑处理部分:

服务端相应

string uploadFolder = "myupload"; // 上传文件夹
protected void Page_Load(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;

if (files.Count == 0)
{
Response.Write("请勿直接访问本文件");
Response.End();
}

string path = Server.MapPath(uploadFolder);

// 只取第 1 个文件
HttpPostedFile file = files[0];

if (file != null && file.ContentLength > 0)
{
// flash 会自动发送文件名到 Request.Form["fileName"]
string savePath = path + "/"+Request.Form["fileName"];
file.SaveAs(savePath);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: