开发者

Validation on Video size? (regular expression?)

In my web application while uploading a video file i restrict the user to upload up to 10 mb not more than 10 Mb, i write code for this, but can i get regular exp开发者_运维问答ression for size of the video, when user upload the video in fileupload control. Thank you.


long numBytes = this.FileUpload1.FileBytes.Length;
double dLen = Convert.ToDouble(numBytes / 1000000);

dLen will be the size in MB.


You could do this in ASP.NET but it's better to check locally with JavaScript as well to avoid wasting bandwidth. The file selector input box has some file-related properties, such as this one that you can check to see it's under 10MiB before uploading.

fileInput.files[0].size;

So, your check would be:

if (fileInput.files[0].size > 10485760) ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜