您的位置:首页 > Web前端 > JQuery

jQuery Ajax上传文件

2016-03-24 11:47 435 查看
JS代码:

//首先判断路径是否存在,不存在则创建路径
string path = Path.Combine(System.Configuration.ConfigurationManager.AppSettings["UploadsFiles"], folder + "/" + DateTime.Now.ToString("yyyyMMdd") + "/");
string physicalPath = server.MapPath(path);
if (!Directory.Exists(physicalPath))
{
Directory.CreateDirectory(physicalPath);
}

HttpPostedFileBase file = request.Files[0];
string newFileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName);
string savePath = Path.Combine(physicalPath, newFileName);
file.SaveAs(savePath);
fileName = file.FileName;
string url = Path.Combine(path, newFileName);
return url;


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: