Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
When i make FileUpload control in asp.net from .aspx.cs code file , it shows hasfile false

how to make hasfile true

I need to make FileUpload control to save file in folder using

string paths=Path.Conbine(@"C:/Forms/","jackpot.jpg");
FileUpload fup=new FileUpload();

fup.Saveas(paths);

the above bold line copies file to folder..

Also , i get filename(imagename) , from <input type="file">

and i use <input type="file"> because, there are multiple input type="file" which are appended from jquery
Posted
Comments
JoCodes 27-Jan-14 0:08am    
You mean to say despite of selecting the file to upload by the fileupload control its showing HasFile as false?Are you using Update panel ?

1 solution

You cannot make FileUpload.HasFile true: the user has to initiate the upload, you cannot do it from the server.

Think about it: if you could start an upload from your server, then any website you visit could upload any file it wanted from your PC at any time it desired. Security (understandably and thankfully) prevents this!
 
Share this answer
 
Comments
maulikshah1990 26-Jan-14 5:13am    
But if i want to save file selected using Input type="file" , and save it in folder

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