Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    save image from byte array

    Dear All,

    I am trying to save a byte array as an image. this byte array may be retrieved from database or it could be retrieved from fileupload control. Then I want to show this image on web page. But this image is not displayed on web page. Here is my code;

    ////////////

    byte[] image = new byte[FileUpload1.PostedFile.ContentLength];

    HttpPostedFile uploadedImage = FileUpload1.PostedFile;

    MemoryStream ms = new MemoryStream(image);

    System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);

    string path = Path.GetTempPath();



    path += "chuss.png";



    returnImage.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);

    Session["image"] = path;

    this.Image1.ImageUrl = path;

    //////////////////////////



    Any help will be greatly appreciated.

  • #2
    New to the CF scene
    Join Date
    Jan 2010
    Location
    New Delhi, India
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    You are using string path = Path.GetTempPath();

    In General, you are only able to access files inside root directory where your website files exists.

    Try to use a folder inside your root directory to save the files.


    Regards,
    Gaurav


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •