gpt4 book ai didi

asp.net - InputFile.PostedFile.ContentLength 测量单位

转载 作者:行者123 更新时间:2023-12-02 10:23:52 25 4
gpt4 key购买 nike

请告诉我 InputFile.PostedFile.ContentLength 测量的单位。我需要确保文件小于 500k。

谢谢。

最佳答案

测量单位 = 字节。

1 Kilobyte (kB) = 2ˆ10 Byte = 1024 Bytes

文件大小为 15 KB 的示例代码测试:

const int maxFileLength = 15360; // 15KB = 1024 * 15

if(PictureFile.PostedFile.ContentLength > maxFileLength)
{

MyResult.Text = String.Format("Your post has a size of {0:#,##0} bytes which
exceeded the limit of {0:#,##0} bytes. Please upload a smaller file.",
PictureFile.ContentLength, maxFileLength);
}
else
{
// Save the file here
MyResult.Text = "Thank you for posting."
}

就您的情况而言,由于您希望文件小于 500 KB,因此您应该这样:

const int maxFileLength = 512000; // 500KB = 500 * 1024

关于asp.net - InputFile.PostedFile.ContentLength 测量单位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3698122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com