Click here to Skip to main content
15,867,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone,

i am having problem while uploading the pdf file on server. i am using the following code for uploading the pdf file on database, in local server it's working fine. but when i use this code on server it's not working .

following code :

C#
protected void btnsave_Click(object sender, EventArgs e)
    {
        if (flUpld.HasFile == false)
        {
            lblerror.Text = "select a file to upload";
        }
        else
        {
            try
            {
                string filename = flUpld.FileName;
                find =Request.ApplicationPath;
                flUpld.PostedFile.SaveAs(Server.MapPath(find+"\\results\\" + filename.Trim()));
                string path = find+"\\results\\" + filename.Trim();

                if (ChangeData.InsertResult(ddlcategory.SelectedValue.ToString(), ddlsubcategory.SelectedValue.ToString(),
                txttitle.Text, path))
                {
                    txttitle.Text = "";
                    lblerror.Text = "sucessfully submitted";
                }
                else
                {
                    lblerror.Text = "try again later ";
                }
            }
            catch (Exception ex)
            {
               // Response.Write(ex.ToString());
            }
        }
    }



can anyone customize the code for server..
thanks in advance .
Posted
Comments
Shubham Choudhary 19-Mar-13 2:44am    
hi!! amit can you post the error!!!
amitkumar5734 19-Mar-13 2:48am    
sir.. error is nothing i mean.. when i click on the button for saving . it's not going in try block. it's directly comes in catch block.. tht's y .. no error is occurred.
Ankur\m/ 19-Mar-13 8:46am    
When it comes in the exception block, add a quick watch for ex.Message. Post the result.
AmitGajjar 19-Mar-13 8:49am    
Add breakpoint in the page load event and try to debug one by one line and check from where you are getting issue. also let us know if you place breakpoint in save button, after save button clicked execution stop at debug point ?
amitkumar5734 19-Mar-13 3:27am    
is there any one who can solve this problem

1 solution

as your code is working fine in local machine that means that it is error free. Please do check that the folder in which you are uploading the pdf in the server has write permission enabled or not. If not then enable the write permission for that particular folder. and everything will work fine.
 
Share this answer
 
v2

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