title: How to upload an image using fileupload control and save it in a different location
body: <p>I have developed a mvc4 razor web application to upload an image of a person and save it in a custom loaction(folder).</p>
  
  <p>it has a fileupload control, a textbox and a button. When i upload an image using file upload control, i need to save it in a custom location like "D:/Employee/ContactImage" and file name should be the value typed in textbox.</p>
  
  <p>here is the code in view</p>
  
  <pre><code>&lt;div id="partial"&gt;
              @{Html.RenderPartial("WholeSaleUserDetail");}
              @using (Html.BeginForm("FileUpload", "WholeSaleTrade", new RouteValueDictionary(new { @class = "mainForm" }), FormMethod.Post, new { enctype = "multipart/form-data" }))
              {  
                  &lt;input name="uploadFile" type="file" id="fileUpload"/&gt;
                  &lt;input type="submit" value="Save Image" id="saveImage" /&gt;
                  &lt;input type="text" id="imageName"&gt;
  
              }
              &lt;div style="width: 200px; height: 200px;"&gt;
                  &lt;img id="empimage" src="../../Images/no_image.jpg" alt="" /&gt;&lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>and here is the code for controller class</p>
  
  <pre><code>[HttpPost]
      public ActionResult FileUpload(HttpPostedFileBase uploadFile, string imageName) 
      {
          var j = new ImageJob(uploadFile, "~/Img/resize/" + imageName, new ResizeSettings(300, 300, FitMode.Stretch, "Jpeg"));
          j.Build();
          string imageUrl = PathUtils.GuessVirtualPath(j.FinalPath);
  
          return Json(imageUrl, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>all i need to do here is pass the value of textbox as file name and save the image in the given location.
  please help me here..</p>