之前回答过个类似的问题
是将canvas传到后台
js:
var data = _canvas.toDataURL();
//删除字符串前的提示信息 "data:image/png;base64,"
var b64 = data.substring(22);
$.ajax({ url: "RotateCanvas.aspx", data: { data: b64, name: i.toString() }, success:
function ()
{
alert('OK');
}
});
java:
if (Request["name"] != null)
{
string name = Request["name"];
String savePath = Server.MapPath("~/images/output/");
try
{
FileStream fs = File.Create(savePath + "/" + name + ".png");
byte[] bytes = Convert.FromBase64String(Request["data"]);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
catch (Exception ex)
{
}
}
如果你要用批量上传 最好用控件
jQuery.uploadify
Upload Files | Clear Queue
UploadFileForm.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.ContentType = "text/plain";
Response.Charset = "utf-8";
string strUploadPath = Request.PhysicalApplicationPath + Request.QueryString["folder"].Trim('/').Replace("/", "\\") + "\\";
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile postedFile = Request.Files[i];
string fileName = strUploadPath + Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
postedFile.SaveAs(fileName);
}
}
Response.Write("Upload The File Successfully!");
}
catch (Exception ex)
{
Response.ContentType = "text/plain";
Response.Write(ex.Message);
}
finally
{
Response.Flush();
Response.End();
}
}
你可以百度下 SWFUpload 下载里面的例子,下载下来看下肯定会. 我只有CI框架的SWFUpload例子.