有人能告诉我如何在开始上传之前检查所选文件的文件大小?
<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" />
答案 0 :(得分:1)
创建一个处理程序。
public void ProcessRequest(HttpContext context)
{
HttpPostedFile up = context.Request.Files[0];
if(up.ContentLength > 2097152) // 2MB
{
//your logic here
}
}
答案 1 :(得分:1)
使用RadAsyncUpload,因为它提供了这个OOB:http://demos.telerik.com/aspnet-ajax/asyncupload/examples/validation/defaultcs.aspx