Phi*_*hil 2 vb.net asp.net file-upload maxstringcontentlength filesize
请告诉我InputFile.PostedFile.ContentLength测量的单位.我需要确保文件小于500k.
谢谢.
Len*_*rri 11
计量单位=字节.
1 Kilobyte (kB) = 2ˆ10 Byte = 1024 Bytes
Run Code Online (Sandbox Code Playgroud)
文件大小为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."
}
Run Code Online (Sandbox Code Playgroud)
在您的情况下,如您所希望的文件小于500 KB,您应该这样:
const int maxFileLength = 512000; // 500KB = 500 * 1024
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18736 次 |
| 最近记录: |