ajaxfileupload上传文件成功,但是无法获取到值
<script src="~/Scripts/json2.js"></script>
<script src="~/Scripts/ajaxfileupload.js"></script>
<script>
<div style="padding-left: 80px;">
<input id="fileUpload1" name="fileUpload1" type="file" />
<br />
<br />
name值必须有的!
<br />
<br />
<input type="button" id="btnReader" name="btnReader" value="确定" style="width: 80px; height: 35px" οnclick="reader()" />
</div>
function reader()
{
$.ajaxFileUpload({
url: '../TxtReader/Reader',
// cache: false,
// async: false,
fileElementId: 'fileUpload1',
dataType: 'json',
success: function (data, status) {
alert("Success");
} ,
error: function (data, status, e) {
alert(e);
}
});
}
</script>
/// <summary>
/// 读取文件
/// </summary>
/// <returns></returns>
public string Reader()
{
HttpFileCollectionBase files = Request.Files;
HttpPostedFileBase file = files["fileUpload1"];
string filepath;
string filename;
if (file == null || file.ContentLength <= 0)
{
return "0"; //没有选择需要的上传文件
}
try
{
filepath = GetMapPath("../ExcelFolder/");
filename = Guid.NewGuid().ToString() + file.FileName.Substring(file.FileName.IndexOf('.'));
file.SaveAs(Path.Combine(filepath + filename));
}
catch (Exception err)
{
}
return "0";
}
/// <summary>
/// 获得当前绝对路径
/// </summary>
/// <param name="strPath">指定的路径</param>
/// <returns>绝对路径</returns>
public string GetMapPath(string strPath)
{
if (HttpContext.CurrentHandler != null)
{
return HttpContext.Server.MapPath(strPath);
}
else //非web程序引用
{
strPath = strPath.Replace("/", "\\");
if (strPath.StartsWith("~"))
{
strPath = strPath.TrimStart('~');
}
if (strPath.StartsWith("\\"))
{
strPath = strPath.TrimStart('\\');
}
if (strPath.Substring(0, 4) == "bin\\")
{
strPath = strPath.Substring(4);
}
return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
}
}
- 使用ajaxfileupload.js进行文件上传,文件可以上传成功,但是不走success回调函数解决办法
- 使用ajaxfileupload.js进行文件上传,文件可以上传成功,但是不走success回调函数解决办法。
- 使用ajaxfileupload.js上传文件成功之后,没有执行success方法
- ajaxFileUpload 上传文件/图片,传参数,解决第二次无法上传问题
- ajaxfileupload上传文件成功后总是指向error
- 使用ajaxfileupload.js上传文件成功之后,不走success的解决方法
- 使用插件ajaxfileupload通过ajax方式上传文件,在火狐下出错
- SpringMVC结合ajaxfileupload.js实现文件无刷新上传
- Ajaxfileupload 上传文件后返回response的contentType错误问题
- jquery 文件上传插件ajaxfileupload.js 实现多图上传,解决文件上传后表单置空的问题
- IE8下面的ajaxfileupload的上传文件处理。
- ajaxFileupload.js修复上传无法携带参数,返回json格式不准确问题
- SpringMVC + ajaxfileupload的多文件上传
- SpringMVC+ajaxFileUpload.js实现文件上传
- ajaxFileUpload+struts2实现异步上传文件
- AjaxFileUpload.js实现异步上传文件
- SpringMVC结合ajaxfileupload.js实现ajax无刷新文件上传
- 后台使用Spring MVC 4.15 版本 通过 ajaxFileUpload plugin插件上传文件相应时引起的一个小问题,Chrome、Firefox中出现SyntaxError:unexpected token <
- SpringMVC结合ajaxfileupload文件无刷新上传
- Jfinal框架下结合ajaxFileupload实现多文件上传