Download File in flash 8

  • James R
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 17, 2007
  • Posts: 6
  • Loc: Dublin
  • Status: Offline

Post January 23rd, 2007, 1:27 pm

I'm getting this:

" header('Content-disposition: attachment; filename=trigger--januarys_blue[jan_07].mp3'); header('Content-type: audio/mp3'); download file "

:-S
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 23rd, 2007, 1:27 pm

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post January 23rd, 2007, 11:23 pm

did u use the head tag?
Code: [ Select ]
<html>
 <head>
   header('Content-disposition: attachment; filename=filename.jpg');
   header('Content-type: audio/mp3');
 </head>
<body>
  <a href="trigger--januarys_blue[jan_07].mp3">download file</a>
</body>
</html>
  1. <html>
  2.  <head>
  3.    header('Content-disposition: attachment; filename=filename.jpg');
  4.    header('Content-type: audio/mp3');
  5.  </head>
  6. <body>
  7.   <a href="trigger--januarys_blue[jan_07].mp3">download file</a>
  8. </body>
  9. </html>

for this u should only have: download file
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • Xarathal
  • Born
  • Born
  • User avatar
  • Joined: Apr 20, 2007
  • Posts: 3
  • Status: Offline

Post April 20th, 2007, 5:24 pm

By the way, you can also use the Flash "FileReference.download" method to download files, and you don't need any PHP. It's pretty slick:

public download(url:String, [defaultFileName:String]) : Boolean

Code: [ Select ]
import flash.net.FileReference;

var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {
  trace("onSelect: " + file.name);
}

listener.onCancel = function(file:FileReference):Void {
  trace("onCancel");
}

listener.onOpen = function(file:FileReference):Void {
  trace("onOpen: " + file.name);
}

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
  trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

listener.onComplete = function(file:FileReference):Void {
  trace("onComplete: " + file.name);
}

listener.onIOError = function(file:FileReference):Void {
  trace("onIOError: " + file.name);
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf";
if(!fileRef.download(url, "FlashPlatform.pdf")) {
  trace("dialog box failed to open.");
}
  1. import flash.net.FileReference;
  2. var listener:Object = new Object();
  3. listener.onSelect = function(file:FileReference):Void {
  4.   trace("onSelect: " + file.name);
  5. }
  6. listener.onCancel = function(file:FileReference):Void {
  7.   trace("onCancel");
  8. }
  9. listener.onOpen = function(file:FileReference):Void {
  10.   trace("onOpen: " + file.name);
  11. }
  12. listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
  13.   trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
  14. }
  15. listener.onComplete = function(file:FileReference):Void {
  16.   trace("onComplete: " + file.name);
  17. }
  18. listener.onIOError = function(file:FileReference):Void {
  19.   trace("onIOError: " + file.name);
  20. }
  21. var fileRef:FileReference = new FileReference();
  22. fileRef.addListener(listener);
  23. var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf";
  24. if(!fileRef.download(url, "FlashPlatform.pdf")) {
  25.   trace("dialog box failed to open.");
  26. }

For more info on the download method, look up the FileReference class and look at the download method.

One thing to bear in mind: the url MUST be a http or https request.

Rock on,

--eric
http://www.thecosmonaut.com
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Joined: Aug 06, 2003
  • Posts: 6892
  • Loc: up a tree
  • Status: Offline

Post September 10th, 2007, 10:53 pm

IceCold wrote:
create a html page with this code inside it, place it on the server and see if it downloads it when u press the link:
Code: [ Select ]
<html>
header('Content-disposition: attachment; filename=filename.jpg');
header('Content-type: audio/mp3');
<body>
  <a href="trigger--januarys_blue[jan_07].mp3">download file</a>
</body>
</html>
  1. <html>
  2. header('Content-disposition: attachment; filename=filename.jpg');
  3. header('Content-type: audio/mp3');
  4. <body>
  5.   <a href="trigger--januarys_blue[jan_07].mp3">download file</a>
  6. </body>
  7. </html>

But, if you want dynamic links ... you will need a server side script.


What happens with the header code if you have more than one file you want to allow people to download, say 40 or so?

Cheers.
Opportunity To Do - Changing the lives of children around the world.
Rose.id.au - Doing Life.

Post Information

  • Total Posts in this topic: 19 posts
  • Users browsing this forum: No registered users and 45 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.