Click here to Skip to main content
15,902,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I m uploading the client's image to a server folder and I save that link to the database. The image is loaded using FileUpload and saved to a specific server folder and the path is saved to the database. But the image can not be displayed in an image control while uploading the photo. How can I fix this?

Here is my code:

C#
s= browser.FileName.ToString() ;
//photoid.ImageUrl = s;
photoid1.Src = s;
if ((this.browser.PostedFile != null) && (this.browser.PostedFile.ContentLength > 0))
{
     FileName = System.IO.Path.GetFileName(browser.PostedFile.FileName);
     //SaveLocation = Server.MapPath("PhotoId")+"\\" + FileName;
    SaveLocation ="D:\\Sagar\\Bulk Transportation\\Bulk Transportation\\PhotoId\\"+ FileName;
    
    this.browser.PostedFile.SaveAs(SaveLocation);
    //photoid.ImageUrl = SaveLocation;//this.browser.PostedFile.FileName;
    //photoid1.Src = SaveLocation;
}
    btnloadimage.Text = "Save Image";
    if (s != "")
    {
        browser.Visible = false;
        btnloadimage.Text = "Load Photo";
    }
Posted
Updated 4-Feb-10 2:22am
v5

Have you checked that the destination directory has sufficient access rights and that web.config for the entire directory tree will allow it?
 
Share this answer
 
You should have either the folder where you place the images accessible from the client, or you have created one Image Handler to write the contents of the image directly in the response.

Place the images just under any folder within your virtual directory. Your client can access it.

See, if your src = "/images/x.jpg"
it accesses a folder images just under your published folder.

If you write
src="D:\docs\x.jpg"

No meaning to the client.

:cool:

Still have confusion, let me know.
 
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