title: How to resize image upon uploading to database in asp.net mvc?
body: <p>i want to resize an image before it is saved on my mysql database..
  how will i process it?
  i have here the code for view, controller, and model.</p>
  
  <p>View:</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" action="&lt;%=url.action("PhotoInsert") %&gt;"&gt;
      &lt;%Using Html.BeginForm()%&gt;
      &lt;p&gt;
      &lt;label for="despcription"&gt;Caption :&lt;/label&gt;
      &lt;%=Html.TextArea("caption")%&gt;
      &lt;/p&gt;
      &lt;p&gt;
      &lt;label for="image"&gt;Image : &lt;/label&gt;
      &lt;input type="file" id="image" name="image" /&gt;
      &lt;/p&gt;
      &lt;input type="submit" value="Insert" /&gt;
      &lt;%End Using%&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>Function PhotoInsert(ByVal caption As String, ByVal image As HttpPostedFileBase) As ActionResult
      UploadDirectory = Path.GetDirectoryName(Request.PhysicalApplicationPath)
      Dim fileName As String = Path.GetFileName(image.FileName)
      Dim fullUploadpath As String = Path.Combine(UploadDirectory, fileName)
      image.SaveAs(fullUploadpath)
      dPhotos.pictureInsert(image:=image.FileName, caption:=caption)
  End Function
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>Imports Microsoft.VisualBasic
  Imports System.Data
  
  Public Class ClassPhotosConnection
  Inherits ClassConnection
      Public Sub pictureInsert(ByVal image As String, ByVal caption As String)
      Dim insert As String = String.Format("INSERT INTO pictures(Image, Caption) VALUES  ('{0}','{1}')", image, caption)
      UpdateData(insert)
      End Sub
  End Class
  </code></pre>
  
  <p>Thank you!:)</p>