Uploading images to ASP.NET MVC website and saving them in a database
<p>I have a page where a client wants to upload images of kitchens and add a bit of text + a title to each. Right now my solution supports uploading images via URLs, but I want the client to be able to upload his own images from his computer onto the site via a "Browse" button.</p>

<p>This is my current model class:</p>

<pre><code>public class Udstillingsmodel
{
    public int ID { get; set; }
    public string titel { get; set; }
    public string beskrivelse { get; set; }
    public string billedeSti { get; set; }
}

public class UdstillingsmodelDBContext : DbContext
{
    public UdstillingsmodelDBContext() : base("UdstillingsmodelDBContext") { }
    public DbSet&lt;Udstillingsmodel&gt; Udstillingsmodels { get; set; }
}
</code></pre>

<p>This is where I have the button placed currently, in the "Create" view for the model controller:</p>

<pre><code>&lt;div class="form-group"&gt;
        &lt;div class="control-label col-md-2"&gt;
            &lt;p&gt;&lt;b&gt;Billede:&lt;/b&gt;&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class="col-md-10"&gt;
            &lt;input type="file" accept="image/png, image/jpeg, image/gif" name="image" /&gt;
            @Html.EditorFor(model =&gt; model.billedeSti, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model =&gt; model.billedeSti, "", new { @class = "text-danger" })
        &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>These are the two GET and POST methods for the Create function:</p>

<pre><code>// GET: Udstillingsmodels/Create
public ActionResult Create()
    {
        return View();
    }

    // POST: Udstillingsmodels/Create
    // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
    // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create([Bind(Include = "ID,titel,beskrivelse,billedeSti")] Udstillingsmodel udstillingsmodel)
    {
        if (ModelState.IsValid)
        {
            db.Udstillingsmodels.Add(udstillingsmodel);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        return View(udstillingsmodel);
    }
</code></pre>

<p>I have the image selected via the "Browse" button named "image" as a variable, but I am unsure what to do with this and how to correctly save the image through Entity framework. Right now my "image" property for my model is merely a string, but I was thinking that it could point to a location in the contents folder, where all my other images are stored, as I've done elsewhere on the site. Let me know if you need more information and code.</p>

<p>This is how the "Create" view looks currently, with the button added.
<a href="https://i.imgur.com/PgYq9nL.png" rel="nofollow noreferrer">http://i.imgur.com/PgYq9nL.png</a></p>