小编use*_*912的帖子

限制用户上传大文件

请在下面找到我的代码.我试图限制用户上传小于4 MB的文件,但是当我选择830 KB的文件时,我的内容长度为80 MB.
此代码flSignature.PostedFile.ContentLength无效.请帮忙.

TIA

string uploadMsg = "";
string appPath = Server.MapPath("~");
string parentpath = appPath + "\\app\\Pictures\\";
//To Upload Multiple Files on Single Click 
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
    HttpPostedFile hpf = hfc[i];

    if (hpf.ContentLength > 0)
    {
        //if (hpf.ContentLength > 4096)
        //{
        //   uploadMsg = "Collective file size is more than 4 MB.";
        //}
        //else
        //{
        if (hfc.AllKeys[i].Contains("flSignature"))
        {
            if (flSignature.PostedFile.ContentLength > 4096)
            { 
                uploadMsg …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

2
推荐指数
1
解决办法
2582
查看次数

标签 统计

asp.net ×1

c# ×1