Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all I have fileupload functionality in my project.It is working fine for the next page where i retriving the uploaded image from the previous page.But the same code is showing error like cant find path in the subsequent pages when i retrive the image.Iam using session variable to store the image path.
I ll post my code Also

C#
if (Session["ScannedSignaturePath1"] != null && Convert.ToString(Session["ScannedSignaturePath1"]) != "")
           {
               string Path = Session["ScannedSignaturePath1"].ToString();
                  ImgDeclaredScannedSign.ImageUrl = "ImageView.aspx?img=" + Path;

           }


inimageview i written code like
C#
if (Request.QueryString["img"] != null)
            {
                Response.ContentType = "Image/Jpeg";
                Response.WriteFile(Request.QueryString["img"]);
            }
Posted

1 solution

VB
Dim filePath As String = Server.MapPath("YourPathHere") 'Why Server.MapPath?  Because we need the PHYSICAL PATH of the file
Dim targetFile As System.IO.FileInfo = New System.IO.FileInfo(filePath)
If targetFile.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name)
Response.AddHeader("Content-Length", targetFile.Length.ToString)
Response.ContentType = "application/octet-stream"
Response.WriteFile(targetFile.FullName)
 
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