all groups > flash actionscript > february 2004 >
You're in the

flash actionscript

group:

Download file from movie button


Download file from movie button richj55
2/27/2004 7:57:58 PM
flash actionscript:
I need to be able to create a button that allows the user to download a file
directly from the flash movie. File types would include mp3, jpg and pdf. Any
help is appreciated. I don't want to have to zip the file.

Thanks,

Rich
Re: Download file from movie button stwingy
2/27/2004 8:35:04 PM
This is just copied from a recent post by Urami

In any text editor (notePad) paste the following :

<?
Header( "Content-type: image/jpeg");
header("Content-Disposition: attachment; filename=\"".$HTTP_GET_VARS["f"] .
".jpg"."\"");
include($HTTP_GET_VARS["f"] . ".jpg");
?>


call it 'download.php'

than go to it like download.php?f=filename , it will add .jpg itself, for
security reasons.

You don't need to hardcode the extension like I did, but it's better for
security.
You don't want a hacker to go download.php?f=.htpasswd and get your password
file
easiest way is to make a different php for each type you want...
movdownload.php / gifdownload.php

if you want to change to other image just modify image/jpeg -> image/gif
IT works cross OS as long as the file and the script lay on same server with
PHP support.

pretty much it

just in case here is an action sample , you want to download image1.jpg ,
button action will be :

on (release) {
getURL("download.php?f=image1");
}


now , you need to rememebr that the content type changes based on the file
extension :

Header( "Content-type: image/jpeg");

Header( "Content-type: image/gif");

Content-type: application/pdf

Content-Type: audio/x-wav

Content-type: audio/x-mp3
or
Content-Type: audio/mpeg

and

Content-Typ: video/quicktime
Re: Download file from movie button Jaggedge Scythe
4/15/2004 3:27:19 AM
Hi, i tried out the script and it works great! however,i'm quite the newbie to
this sort of thing and i dun know how to tweak the settings for my own uses.
could anybody set up an example, with a file "test.jpg", if it's not too much
trouble?

haha, so far when i click on the button,the save dialog comes up and asks me
where i wish to save the "download.php" file! *sheepish*
AddThis Social Bookmark Button