Download image(s) from the web

You can use the method HTTPDownload() or HTTPDownloadEx() to download an image from the web server into Dynamic Web TWAIN. It is useful when you want to review an image created and uploaded by Dynamic Web TWAIN.

DWObject.HTTPDownload("", "/images/dwt-logo.png", 
optionalAsyncSuccessFunc, optionalAsyncFailureFunc);

//Callback functions for async APIs
function optionalAsyncSuccessFunc() {

function optionalAsyncFailureFunc(errorCode, errorString) {

Even when the image data is stored in the database, you can write an action page to pull the data from the database and get it downloaded (in this case, you need to use the method HTTPDownloadEx() because the image format needs to be specified explicitly). Besides the HTTP download methods, you can also use the FTP download methods to download image(s) from an FTP server. Available methods are FTPDownload(), FTPDownloadEx(), etc.


When you try to download an image from a server with a different domain, subdomain, port, or protocol, you need to configure your server to allow such requests by adding one HTTP Response Header, namely:

Access-Control-Allow-Origin: *
  • is used here for convenience, you can configure it according to your application security requirements.

Take IIS 7 for example, what you need to do is merge the following lines into the web.config file at the root of your application/site:

<?xml version="1.0" encoding="utf-8"?>
               <add name="Access-Control-Allow-Origin" value="*" />
               <add name="Access-Control-Allow-Methods"
               <add name="Access-Control-Allow-Headers" value="x-requested-with"/>
               <add name="Access-Control-Allow-Credentials" value="true" />

If you don't have a web.config file already, just create a new file called web.config and add the snippet above.

results matching ""

    No results matching ""

    results matching ""

      No results matching ""