【问题标题】:File upload doesn't works from Android browser文件上传不适用于 Android 浏览器
【发布时间】:2015-08-27 03:05:18
【问题描述】:

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>

我也在网络配置服务器中设置:

<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />

但无法从 Android 浏览器上传文件到 IIS 服务器。

【问题讨论】:

  • 给我们更多信息。描述错误。

标签: asp.net-mvc file-upload iis-7 android-browser


【解决方案1】:

与编程无关问题是包的大小在服务器上设置为 MUT 解决了在服务器中将命令提示符上的 MUT 大小设置为默认值 1350

netsh interface ipv4 set subinterface 10 mtu=1350 store=persistent

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多