tags:

views:

13

answers:

2

Hi,

I have follow code in a ASP.Net Webpage:

    protected void btnSend_Click(object sender, EventArgs e)
    {
        string imei = Request.QueryString["id"];
        int imeiID = int.Parse(imei);

        if (fuPicture.HasFile)
        {
            fuPicture.SaveAs("/Images/" + imei + ".jpg");
            DAL.ImeiHandling.SavePicture(imeiID, "");
        }

        string code = Request.QueryString["code"];
        Response.Redirect("~/UploadPicture.aspx?id=" + imei + "&code=" + code);
    }

How to fill the SaveAs and how to load the path in a ASP:Image ?

+3  A: 

Save as simply takes a file path, typically you would do something like this.

fleUpload.SaveAs(Server.MapPath("~/Images/Uploadded/new.jpg")) 

or similar, to get a physical file path for the save.

Once it is saved, you can do whatever you want with it.

NOTE: You want to consider security/validation that the user really provided an image etc when doing this.

Mitchel Sellers
How to be sure that it is an image?
Kovu
There are a number of ways, with varying levels of success. The most primitive is to look at the user supplied image type.
Mitchel Sellers
A: 

SaveAs takes a local path (that is local to the web server) as a parameter.

You need to make sure the account that the site is running under has permissions to save to that location.

If you want to load an image from that path, you need to make sure it is mapped within the webserver and can be served from it (using a virtual directory, for example).

You can set the Image.ImageUrl with the virtual path.

Oded

related questions