How do you download product images from a SWF file?

Posted on 2009-04-28
Medium Priority
Last Modified: 2012-05-06
I have a small web site that would have about 25 product images. I would like to have a prospect be able to click on a product image and have it download to their desktop either as low resolution or as a high resolution zipped file.

How do you do this using Actionscript 2?
Question by:rgroft
  • 2
  • 2

Expert Comment

ID: 24256168
To download as a zip, all you need is getURL, since the browser won't attempt to open it anyway - you will get a "save as" dialog.

btn.onRelease = function(){

If you want to download an image as an attachment, things get a little trickier since the default behaviour will be to just display the image. Uou will need a little server-side help to tell the browser it should download the file as an attachment rather than attempting to display it.

Here is an example of how the server side component would work in ColdFusion - there are of course equivalents for ASP or PHP, depending on your favourite:


To use this, you would simply create a server page called "download.cfm" which contains this code and use this Actionscript to call it

btn.onRelease = function(){

If server-side stuff isn't your thing you can get away with just opening the image in a new window, and instructing the user to right-click and "save-as" the image. The following actionscript will open your image in a blank window

btn.onRelease = function(){
    getURL("image.jpg","_blank" );


Author Comment

ID: 24256915
Hi ccarey!

The  "getURL("image.jpg","_blank" );" works. Thank you!

I tried the ColdFusion attempt and the only thing that shows up in the browser window is the "download.cfm" code. I have no clue how to do this one unfortunately.

If I have an image called Pic01, where would I place it in the coding? The cfm or the button code. Also, Would the ASP version be easier?


Accepted Solution

ccarey earned 2000 total points
ID: 24256988
You would need to be hosted on a ColdFusion server for it to process a .cfm file. To use ASP your server needs to be able to interpret ASP. Same for PHP and so on. You'd need to ask your web host what they support.

If your image is called Pic01.jpg your server page would need to be told what file to download - I used ?file=blah below to get the filename from the URL.


Here's an equivalent PHP sample:

// We'll be outputting an image
header('Content-type: image/jpg');

// It will be called Pic01.jpg
header('Content-Disposition: attachment; filename="Pic01.jpg"');

//  read the image source

If you google around for ASP content-type header you'll find an ASP equivalent. All the server languages have some permutation of the same thing. Essentially it's just telling your browser "do this with the content I'm supplying"

Author Closing Comment

ID: 31575560
Thank you for your help. i will check out the ASP style.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question