prevent upload control from uploading a blank file

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 41
Reputation: julseypart is an unknown quantity at this point 
Solved Threads: 0
julseypart julseypart is offline Offline
Light Poster

prevent upload control from uploading a blank file

 
0
  #1
Feb 23rd, 2009
hi, i have set a condition on the upload function

  1. if (FileUploadControl1.PostedFile == null) {
  2.  
  3. lblResult.Text = "Please select a file first";
  4.  
  5. }
  6.  
  7. else
  8.  
  9. {
  10. //upload a file
  11. }

but if i press upload button when no file is selected it still uploads a blank file regardless of the "if' condition i set, does any1 know why this might be?

cheers
Last edited by peter_budo; Feb 24th, 2009 at 7:28 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: prevent upload control from uploading a blank file

 
0
  #2
Feb 24th, 2009
Try this:
if (FileUploadControl1.HasFile)
{
    //upload a file   
}
else
{
    lblResult.Text = "Please select a file first";   
}
Falling down is not defeat...
Defeat is when you refuse to getup...
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 41
Reputation: julseypart is an unknown quantity at this point 
Solved Threads: 0
julseypart julseypart is offline Offline
Light Poster

Re: prevent upload control from uploading a blank file

 
0
  #3
Feb 25th, 2009
thanks that worked!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC