Click here to Skip to main content
15,914,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to upload file automatically when we browse file to upload?
Posted
Comments
RaisKazi 3-Nov-11 6:02am    
Can you elaborate more?
_Tushar Patil 3-Nov-11 6:05am    
can't understand your question..?
Richard MacCutchan 3-Nov-11 6:13am    
Please stop reposting this. you have already been given some suggestions; go back to your original question if you have further queries.

1 solution

C#
public void resumeinsert()
    {
        //checking Filename is null or not
        if (fileuploadresume.FileName != "")
        {
            //file storing in folder
            string filePath = Server.MapPath("~/pp/") + fileuploadresume.FileName;
            string ext = Path.GetExtension(fileuploadresume.FileName);

            switch (ext)
            {
                case ".doc":
                    contenttype = "application/vnd.ms-word";
                    break;

                case ".docx":
                    contenttype = "application/vnd.ms-word";
                    break;
            }
            //creating file
            fileuploadresume.SaveAs(filePath);
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            bytes = br.ReadBytes((Int32)fs.Length);
            br.Close();
            fs.Close();
            HttpPostedFile myFile = Request.Files[0];
        }

    }
 
Share this answer
 
v2
Comments
Richard MacCutchan 3-Nov-11 6:18am    
Please use proper <pre> tags around your code when posting suggested solutions, as I have done above.

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