title: Uploading Base64 Image to Azure Blob
body: <p>I have the following ASPX markup:</p>
  
  <pre><code>&lt;asp:Image ImageUrl="placeholder.png" runat="server" ID="plhdr" /&gt;
  </code></pre>
  
  <p>The webpage lets a user upload an image, which is processed through a JavaScript library and then set as the source of the above control. The JavaScript sets the source as a Base64 String like this: </p>
  
  <blockquote>
    <p>data:image/jpeg;base64,/9j/4AAQ...</p>
  </blockquote>
  
  <p>I have a function on the same page that is meant to upload the displayed image to Azure Storage and then add a reference to it in Azure SQL. The code I have in the code behind is:</p>
  
  <pre><code>    StorageCredentials creden = new StorageCredentials(accountname, accesskey);
      CloudStorageAccount acc = new CloudStorageAccount(creden, useHttps: true);
      CloudBlobClient client = acc.CreateCloudBlobClient();
      CloudBlobContainer cont = client.GetContainerReference("testcont");
      cont.CreateIfNotExists();
      cont.SetPermissions(new BlobContainerPermissions
      {
          PublicAccess = BlobContainerPublicAccessType.Blob
      });
      CloudBlockBlob cblob = cont.GetBlockBlobReference("cblob");
  
      var imagesrc = plhdr.ImageUrl;
  
      cblob.UploadFromFile(@imagesrc);
  
      var imageUrl = cblob.Uri;
  </code></pre>
  
  <blockquote>
    <p>Server Error in '/' Application. Could not find a part of the path
    'D:\Windows\system32\placeholder.png'. Exception Details:
    System.IO.DirectoryNotFoundException: Could not find a part of the
    path 'D:\Windows\system32\dist\img\fling\space.gif'.</p>
  </blockquote>
  
  <p>At this line: <code>cblob.UploadFromFile(@imagesrc);</code>.</p>
  
  <p>Hoping someone can point me in the right direction.</p>