Click here to Skip to main content
15,867,979 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
function validatefileupload(Source, args)
{
  var fuData = document.getElementById('<%= FileUpload1.ClientID %>');
  var FileUploadPath = fuData.value;
  if(FileUploadPath =='')
  {
    // There is no file selected
    args.IsValid = false;
  }
  else
  {
    var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();
    if (Extension == "jpg" || Extension == "gif" || Extension=="png" || Extension=="jpeg")
    {
      args.IsValid = true; // Valid file type
    }
    else
    {
      args.IsValid = false; // Not valid file type
    }
   }
}


When I am selecting a file, it is not working correctly. Please tell me what is wrong in this code.
ACtually , when i upload any image it display the error message !!!... not going furthur ..
Posted
Updated 6-Dec-10 5:10am
v5
Comments
thatraja 6-Dec-10 2:10am    
do you find any error message? if yes then include that in your question.
Ankur\m/ 6-Dec-10 2:19am    
"When I am selecting a file, it is not working correctly."
Could you please add more details to the statement? Do you see an unexpected behavior or do you get some error or something?
Brij 6-Dec-10 2:33am    
Did you try to debug it. Whether your validation gets fired?

1 solution

Attach debugger; at the very first line of your function.
step into the function and see what happens.

And post exact scenario here when you stuck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900