473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Download via Flash

neliy
32
Hey there. I need to add a link in my current project from which the user will be able to download some images. I tried to find a tutorial to find the way or an actionscript example but I couldn't. Can someone help me plz? thnx
Sep 5 '07 #1
6 4160
xNephilimx
213 Expert 100+
Hi, neliy.
I don't anderstand what are you trying to do... You mean, adding a link that when the user clicks it it is promped to download the file (without givin the option to view it)?

Kind regards,
The_Nephilim

Hey there. I need to add a link in my current project from which the user will be able to download some images. I tried to find a tutorial to find the way or an actionscript example but I couldn't. Can someone help me plz? thnx
Sep 6 '07 #2
neliy
32
Hi, neliy.
I don't anderstand what are you trying to do... You mean, adding a link that when the user clicks it it is promped to download the file (without givin the option to view it)?

Kind regards,
The_Nephilim
Exactly what you said. The images are already viewable by thumbs and by clicking on it I need the download file window to appear in order for the user to get the image. Plz help
Sep 6 '07 #3
xNephilimx
213 Expert 100+
Oh, ok.
That can be done only server side, in my case php. There's no way to do it client-side.
The getURL method in ActionScript should read this for example:
Expand|Select|Wrap|Line Numbers
  1. getURL("download.php?f=path/to/image.jpg");
  2.  
the download.php is the php file that will handle the file to be downloaded, the f=path/to/image.jpg is a variable f being passed in GET method to the donwload.php file, so it will know which file must be used and where it is.

The code in php should be like this:
[PHP]
<?php

$thefile = $_GET['f'];
$ext = substr($thefile,-3);
if($ext == "jpg") $ext = "jpeg";
header('Content-type: image/' . $ext);
header('Content-Disposition: attachment; filename="' . $thefile . '"');
readfile($thefile);

?>
[/PHP]

The first line, just catches the f parameter passed through the URL (GET method) and stores it in the $thefile variable.
The second line extracts the last 3 characters -the extension of the file- and stores it in $ext.
Then if the extension is jpg it changes it to jpeg because when we define the content-type, the jpg content-type is image/jpeg, but the rest could be image/gif and image/png if those where the cases.
So then we define the actual content-type, then the content-disposition, that is how will be the content treated as, in this case like an attachment, adn we pass as the filename prameter the file that was passed from flash.
Then we output the file with the read function, that way our php file "becomes" the image to be downloaded.
The browser then will prompt the user to download the file.

Kind regards,
The_Nephilim

Exactly what you said. The images are already viewable by thumbs and by clicking on it I need the download file window to appear in order for the user to get the image. Plz help
Sep 6 '07 #4
neliy
32
That was more than I was expected! your a legend! thank you
Sep 7 '07 #5
xNephilimx
213 Expert 100+
LOL! You're welcome!
Glad it helped you.

Best regards,
The_Nephilim

That was more than I was expected! your a legend! thank you
Sep 7 '07 #6
This is awesome. I was looking for a way to do this as well. I am using it to download an xml file. The person can then make changes and upload it again. The problem I am having is that safari will not let the xml file download. Works fine in firefox though. Any ideas to make this work in safari.
Feb 10 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: lawrence | last post by:
Under the domain publicpen.com I've several dozen sites in subdiretories, such as www.publicpen.com/honenbeger. I've no trouble with any of these sites. But under one, which I put in yesterday,...
0
by: Martin Raychev | last post by:
Hi everybody, I have a need for a web app that will allow a flash client to download files at a specified speed. I am using Flash for an application of mine which downloads JPG slides to...
0
by: Sarah Akers | last post by:
GgF ----gL5cJ72EqiGIQ0SK65Rz Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html> <head> <style type=3D"text/css">.eyebrow { FONT-WEIGHT: bold; FONT-SIZE: 10px; TE=
0
by: Anne Snow | last post by:
7qs ----bSCMEc0pLIbJxmV9 Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html><head><style type=3Dtext/css>.eyebrow { FONT-WEIGHT: bold; FONT-SIZE= : 10px;...
0
by: Lynda Kilgore | last post by:
jGu ----qtHwhORV90yyhqJMOc Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html><head><style type=3Dtext/css>.eyebrow { FONT-WEIGHT: bold; FONT-SIZE= : 10px;...
0
by: Ron Vecchi | last post by:
Hello, Through using this and many other Microsoft dotnet newsgroups I have been pointed towards many helpful open source projects and articles that have helped a great deal in my studies as...
11
by: moondaddy | last post by:
I have images that I need to prevent the user from doing a right click and selecting "Save Picture As"? How can I do this? -- moondaddy@nospam.com
1
by: pixelmeow | last post by:
Hello all, I have just started work on a website that had some obnoxious flash that the owner wanted removed. I removed the intro page and two flash objects from the index page. The owner then...
12
by: Bob Bedford | last post by:
I've to build a website where the customer can buy an image. I'm thinking in the 2 ways to let people get those images: receive them by Email or send them an image link wich validity is limited in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.