文件上传不适用于Android浏览器,但在PC浏览器中运行良好。我的MVC代码在本地IIS Express中运行良好
[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>
我也在web配置服务器中设置:
<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
但是将文件从Android浏览器上传到IIS服务器并不起作用。
答案 0 :(得分:0)
与编程无关问题是在服务器上为MUT设置了包的大小 在服务器的命令提示符下使用设置的MUT大小解决为默认值1350
netsh interface ipv4 set subinterface 10 mtu = 1350 store = persistent