locked
Problem in File Upload with Tamperdata plugin RRS feed

  • Question

  • I want to upload txt files.
    For this I have placed CustomValidator which checks the extension of the file.
    But, with tamperdata plugin if i change the file name of the upload file CustomValidator's ServerValidate event will not execute.
    Please help me on this issue.
    private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
    		{
    			string UploadFileName = FileUpload.PostedFile.FileName;
     
    			if(UploadFileName == "")
    			{
    				// There is no file selected
    				args.IsValid = false;
    			}
    			else
    			{
    				string Extension = UploadFileName.Substring(UploadFileName.LastIndexOf('.') + 1).ToLower();
     
    				if (Extension == "txt")
    				{
    					args.IsValid = true; // Valid file type
    				}
    				else
    				{
    					args.IsValid = false; // Not valid file type
    				}
    			}
    		}

    Regards,
    Jaydeep
    • Moved by Harry Zhu Monday, November 30, 2009 3:34 AM (From:Visual C# Language)
    Friday, November 27, 2009 7:16 AM

All replies