Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Upload / Validating invalid file path in the file upload control

Validating invalid file path in the file upload control

Article Info

Rating: 2

Article information

Article relates to

 all versions of RadControls

Created by

 Rumen, Telerik

Last modified

 March 21, 2008 

Last modified by

 Sophy, Telerik

Browsers

 Internet Explorer



QUESTION
Is there a way to validate invalid file paths in the file upload control? If the user enters a path like "aaaaa" there is no error reported to the user, the form does not submit, it just stays doing nothing. In this case the user would be wondering why nothing happened.


ANSWER
RadUpload and asp:FileUpload controls render as <input type=”file”> HTML elements, which are used for file selection and uploading. The normal behavior of the browsers is to prevent its javascript engine from setting value of these HTML elements and also to prevent the page from submitting if the selected file does not exist or its path is invalid. The javascript engine is restricted from accessing the client file system, e.g. you cannot access files, located on the client computer using javascript. This limitation makes impossible to check if the selected files exist or not before the page submission.

 

Comments

  • Stephen Morris , Feb 21, 2007

    If a user submits a form with a bad path in the upload control, there is a javascript error and inevitably, the upload control throws a server side error. There's gotta be a way.

  • Telerik Admin , Jun 5, 2007

    There is really no way to get around this.The JavaScript engine is restricted from accessing the client file system and you cannot access files located on the client computer using javascript.

  • aronitin , Jul 16, 2007

    Hi, We can atleast validate the path string for valid physical file path format using refular expression or custom logic. And make the input field read only so that user should always use Select button to select files for uploading.

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.