请在下面找到我的代码.我试图限制用户上传小于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)