0

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 ?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.