In design, I have :
1 FileField, named: FileInput, set runnat="server"
1 Button (of Html toolbox), named: cmdUpload
1 Label (of HTML toolbox), named: lblInfo
First I create function for customer upload their file to server on click event:
Expand|Select|Wrap|Line Numbers
- private void cmdUpload_Click(object sender, System.EventArgs e)
- {
- if (FileInput.PostedFile.FileName == "")
- {
- lblInfo.Text = "No file specified.";
- }
- else
- {
- try
- {
- if (FileInput.PostedFile.ContentLength > 1048576)
- {
- lblInfo.Text = "File is too large.";
- }
- else
- {
- string fileName = Path.GetFileName(FileInput.PostedFile.FileName);
- string filepath = Server.MapPath("") +"\\bin\\CustomerPic\\"+fileName;
- FileInput.PostedFile.SaveAs(filepath);
- lblInfo.Text = "File " + fileName + " uploaded.";
- }
- }
- catch (Exception err)
- {
- lblInfo.Text = err.Message;
- }
- }
- }
Can you give value of FileInput.PostFile in code behind.
Or you can tell me other way to use ajax for FileUpload.
I hope to have true answer than other.
Thanks.