title: Save Base64 to an image using Classic ASP
body: <p>I have been trying to save a base64 file as an image from server side using classic ASP.  What I want is it to autosave the file to a specific location and give it a filename, Now I am fine coding that aspect of it.  However I can't get the code to save the image without first rendering on a browser.  This isn't going to work for me as the script I am using will be an automatic export and have no user input.</p>
  
  <p>Code follows as yet that renders in the webpage and asks the user where to save the image.  Just to reiterate I need it to auto save (no user input)</p>
  
  <pre><code>base64String ="base64 code goes here - Wont add it as its huge amount of text"
  
  Set tmpDoc = Server.CreateObject("MSXML2.DomDocument")
  Set nodeB64 = tmpDoc.CreateElement("b64")
  nodeB64.DataType = "bin.base64" ' stores binary as base64 string
  nodeB64.Text = Mid(base64String, InStr(base64String, ",") + 1) ' append data text (all data after the comma)
  
  vehicleAuditName= "Audit1"
  
  With Response
     .Clear
     .ContentType = "image/png"
     .AddHeader "Content-Disposition", "attachment; filename=" &amp; vehicleAuditName &amp; ".png"
     .BinaryWrite nodeB64.NodeTypedValue 'get bytes and write
     .end
  End With
  </code></pre>