jQuery Ajax上传文件
2016-03-24 11:47
435 查看
JS代码:
View Code
//首先判断路径是否存在,不存在则创建路径 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
相关文章推荐
- jQuery的儿子——jQuery mobile
- jQuery 滚动特效代码
- JQuery遍历 each方法
- jQuery实现滚动按纽特效
- jQuery复习:第四章
- jQuery之.html()和.text()区别
- jquery之empty()与remove()区别
- jQuery学习——ajax的ajaxStart()与ajaxStop()方法
- JQuery.Ajax之错误调试帮助信息介绍
- (jquery.validate.unobtrusive.js)
- 20款最好的jQuery文件上传插件
- jquery根据name取值
- JQuery常用函数及功能小结--转载
- jquery相关注意点
- 对于多个库之间jQuery发生冲突的解决方法
- jQuery的键盘捕获之发现
- jQuery学习之jQuery 简介和安装
- JSON和JSONP (含jQuery实例)(share)
- fetch实践 替代jquery封装的ajax
- jquery.lazyload.js图片延迟加载