Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear file upload text in server side (c#)

I want to clear the file path from the file upload. The file upload is inside the update panel and I am using a AsyncFileUpload. How can I clear the file and change the background color of the fileupload

btnAudUpload_Click Method

string filename =FileUpload.FileName;
string Fullpath = Path.Combine(@"D:\Media", filename);
if (FileUpload.HasFile)
  { 
 if (filename.ToLower().EndsWith("mp4"))
     {  
      //Saving the file
     }
  else
     {
          //I want to clear the  FileUpload content here
     }    
  }
like image 966
Murthy Avatar asked Dec 21 '11 17:12

Murthy


People also ask

How do you delete selected files on file upload control after a successful upload?

bind('focus', function() { // Clear any files currently selected in #upload-file $('#upload-file'). val(''); }) ; // Choose uploading new one - this works ok $('#upload-file'). bind('focus', function() { // Clear any files currently selected in #select-file $('#select-file').

How can remove the value of file upload control in asp net?

Add the functionality of clearing the hasfile property in the LoadPage() function which ,suprise suprise, is called when you refresh (as the page loads). try to deal with the issue immediately after uploading the file.


1 Answers

Clear the Attributes worked for me... but that will remove styles and other stuff

string filename =FileUpload.FileName;
string Fullpath = Path.Combine(@"D:\Media", filename);
if (FileUpload.HasFile)
{ 
  if (filename.ToLower().EndsWith("mp4"))
  {  
     //Saving the file
  }
  else
  {
     //I want to clear the  FileUpload content here
     FileUpload.Attributes.Clear();
  }    
}
like image 133
Gaddiel Sadoc Peralta Avatar answered Oct 21 '22 10:10

Gaddiel Sadoc Peralta