Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want upload a Document in C#
I used the Fallowing code:

C#
if ((FileUpload1.PostedFile != null) &&FileUpload1.PostedFile.ContentLength > 0))
        {

            string fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
            string SaveLocation = Server.MapPath("Uploads") +//+ fn;
            try
            {
                FileUpload1.PostedFile.SaveAs(SaveLocation);
                Label1.Text = "File Uploaded Sucessfully";
            }

            catch (Exception ex)
            {

            }
            finally
            {
            }


it works fine in the visual studio 2005
when i deployed the same its not uploading the the document..
plz help.
Posted
Updated 16-Mar-12 1:56am
v2
Comments
dan!sh 16-Mar-12 8:00am    
What is the error you are getting?
shrikant.kudlur 17-Mar-12 2:21am    
access denied to the folder
ZurdoDev 16-Mar-12 10:18am    
Most likely a permissions error but if you would be so kinds as to share the error message, we could help.
shrikant.kudlur 17-Mar-12 2:21am    
access denied to the folder
ZurdoDev 19-Mar-12 7:57am    
Right, so you'll have to fix the permissions issue first then.

1 solution

C#
if ((docUpload.PostedFile != null) && (docUpload.PostedFile.ContentLength > 0))
            {

                string fn = System.IO.Path.GetFileName(docUpload.PostedFile.FileName);
                string saveLocation = Server.MapPath("~/Uploads/") + fn;
                try
                {
                    docUpload.PostedFile.SaveAs(saveLocation);
                    Label1.Text = "File Uploaded Sucessfully";
                }

                catch (Exception ex)
                {

                }
 
Share this answer
 

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