Asp.net mvc 文件上传不';t在Android浏览器中工作
文件上传在Android浏览器中不起作用,但在PC浏览器中可以正常工作。我的MVC代码在本地IIS express中运行良好Asp.net mvc 文件上传不';t在Android浏览器中工作,asp.net-mvc,file-upload,iis-7,android-browser,Asp.net Mvc,File Upload,Iis 7,Android Browser,文件上传在Android浏览器中不起作用,但在PC浏览器中可以正常工作。我的MVC代码在本地IIS express中运行良好 [HttpPost] public string UploadJson(string id) { try { string uploadFial = "noSave"; if (Request.Files.Count > 0) { var file = Request.Fil
[HttpPost]
public string UploadJson(string id)
{
try
{
string uploadFial = "noSave";
if (Request.Files.Count > 0)
{
var file = Request.Files[0];
if (file != null && file.ContentLength > 0)
{
if (string.IsNullOrWhiteSpace(id)) id = Request.Params["id"];
string fileName = id + Path.GetExtension(file.FileName);
string path = Path.Combine(Server.MapPath("~/Images/"), fileName);
logPath = Path.Combine(Server.MapPath("~/Images/"), "log.txt");
file.SaveAs(path);
return (Request.Url.ToString().Replace(Request.RawUrl.ToString(), "")
+ "/Images/" + fileName);
}
else { return (uploadFial); }
}
else
{ return (uploadFial); }
}
catch (Exception e)
{
saveLog( e.InnerException + "stack trace **" + e.StackTrace+"data **" +e.Data.ToString());
throw e;
}
}
<form action="~/Home/UploadJson/" id="form6" enctype="multipart/form-data" data_ajax="false" method="post">
<input type="file" name="file" />
<input type="submit" value="upload file ready" />
</form>
[HttpPost]
公共字符串上传JSON(字符串id)
{
尝试
{
字符串uploadFial=“noSave”;
如果(Request.Files.Count>0)
{
var file=Request.Files[0];
如果(file!=null&&file.ContentLength>0)
{
if(string.IsNullOrWhiteSpace(id))id=Request.Params[“id”];
字符串fileName=id+Path.GetExtension(file.fileName);
字符串路径=path.Combine(Server.MapPath(“~/Images/”),文件名);
logPath=Path.Combine(Server.MapPath(“~/Images/”),“log.txt”);
file.SaveAs(路径);
return(Request.Url.ToString().Replace(Request.RawUrl.ToString(),“”)
+“/Images/”+文件名);
}
else{return(uploadFial);}
}
其他的
{返回(上传);}
}
捕获(例外e)
{
saveLog(e.InnerException+“stack trace**”+e.StackTrace+“data**”+e.data.ToString());
投掷e;
}
}
我还在web配置服务器中设置:
<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
但将文件从Android浏览器上传到IIS服务器不起作用。与编程无关,问题是服务器上的MUT设置了包的大小 通过将服务器中命令提示符上的MUT size设置为默认值1350解决 netsh接口ipv4集子接口10 mtu=1350存储=持久
给我们更多的信息。描述错误。