title: Uploading image file to server asp.net
body: <p>I have an asp.net project and I am saving selected image to NewUrunler1 file and I am saving image's path in my database. In local, it works without a problem but since I moved my project to my godaddy host, saving method gives an error. Here is my code to save image:</p>
  
  <pre><code>protected void UploadImage()
      {
          try
          {
              HttpPostedFile yuklenecekDosya = FileUploadImage.PostedFile;
              if (yuklenecekDosya != null)
              {
                  FileInfo dosyaBilgisi = new FileInfo(yuklenecekDosya.FileName);
                  string yuklemeYeri = Server.MapPath("~/Images/NewUrunler1/" + dosyaBilgisi);
                  FileUploadImage.SaveAs(Path.Combine(yuklemeYeri));
              }
          }
          catch (Exception e)
          {
              failDiv.Visible = true;
              lblHata.Text = e.ToString();
          }
      }
  </code></pre>
  
  <p>When I run this I get an error from try catch. Here is the error:</p>
  
  <pre><code>System.UnauthorizedAccessException: Access to the path 'G:\PleskVhosts\ada-crm.com\httpdocs\Images\NewUrunler1\deneme.png' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at CRM.UrunEkle.UploadImage()
  </code></pre>
  
  <p>I am new in asp.net so sorry if it is an easy question but I searched in web and couldn't solve it. Thank you for your time.</p>