在开始上传之前,改进RadFileUpload以检查250MB的文件大小?

时间:2014-08-18 18:20:04

标签: asp.net telerik

有人能告诉我如何在开始上传之前检查所选文件的文件大小?

<telerik:RadUpload ID="fuUploadFile" runat="server" ControlObjectsVisibility="None"
    OnClientFileSelected="validationFailed" InputSize="50" TargetFolder="\Upload" AllowedFileExtensions=".wav,.mp3,.mpeg,.mpg,.wmv,.avi,.mp4" />
<telerik:RadProgressArea ID="RadProgressArea1" runat="server" BackColor="#668B8B"
    ToolTip="Uploading " >
</telerik:RadProgressArea>
<telerik:RadProgressManager ID="RadProgressManager1" runat="server"  />
<asp:CustomValidator ID="CustomValidatorUploadFile" runat="server" Display="Dynamic"
    ClientValidationFunction="validateFile" CssClass="RedItalic1" Text="... error text here" />

2 个答案:

答案 0 :(得分:1)

创建一个处理程序。

public void ProcessRequest(HttpContext context)
{
    HttpPostedFile up = context.Request.Files[0];
    if(up.ContentLength > 2097152)    // 2MB
    {
        //your logic here
    }
}

答案 1 :(得分:1)