Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,


In my application I am using the document upload. I will paste my whole application in the server, there is the folder named as Enclosure. When I click the upload button the file will be stored in that folder.And i have one button to open that attached file it is working fine in local system, but it is not working for that server system it is not throwing any error. Can anyone help me to solve this problem.

Here is my Show button Code;

C#
protected void btnenshow_Click(object sender, ImageClickEventArgs e)
   {
       string DirectoryPath = Server.MapPath("") + System.IO.Path.DirectorySeparatorChar + "Enclosure";

       docFileNameWithPath = DirectoryPath + "\\" + lstUpload.SelectedValue;
       string filename = lstUpload.SelectedValue;
       string str = "http://" + Request.Url.Authority + Request.ApplicationPath + "/Enclosure/" + filename;
       if (System.IO.File.Exists(docFileNameWithPath))
           Process.Start(str);

}


Regards
Nanda
Posted
Comments
Tejas Vaishnav 24-Sep-12 6:38am    
what is the error message?
Member 9345484 24-Sep-12 6:57am    
Not showing any error

It is opening.

It is opening on the Server, exactly as it did when you tested it in development. The trouble is, when you tested it, the Server and the Client were the same machine. Now, the client is one machine, and the server is another. When you issue Process.Start on the server, the application runs on the server, not the client.

You cannot reliably execute an application on the client from the server except under very specific circumstances which will not occur in 99% of situations.
 
Share this answer
 
Try this code.....

try
{
string filename = Path.GetFileName(FileUpload1.FileName);

FileUpload1.SaveAs(Server.MapPath("~\\") + "\\Request form\\" + TextBox4.Text + "_" + filename);
Session["val"] = "~\\Request form\\" + TextBox4.Text + "_" + filename;
Label4.Text = "Upload status: File uploaded!";
}
catch (Exception ex)
{
Label4.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
 
Share this answer
 
Comments
Member 9345484 24-Sep-12 7:27am    
File is uploading..... but uploaded file is not opening when i click on show button
Hi,

Use Response.Redirect.

Pass the FileName with its path to download / view.

The Other method ca be found below (Using System.Diagnostics.Process)
http://support.microsoft.com/kb/555134[^]

Regards,
Raghu
 
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