Connecting Tech Pros Worldwide Forums | Help | Site Map

Create limited time download link

Bob Bedford
Guest
 
Posts: n/a
#1: Sep 23 '08
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 time.

The second may help me to know if an image has been downloaded and how many
times.

How to build such download link ?
The informations I'd like is the userid, the datetime limit and the
imagefile, off course everything must be encrypted enough not to let other
people create new links.
Putting the datetime limit in the link allow me not to save this information
in a database. Arriving in the linked script will automatically check the
datetime limit.

I know how to show the picture, that's easy. Now how to make the user
download the image automatically ? not showing the image but instead making
him to "download" the file.

Thanks for advising me about this.

Bob



r0g
Guest
 
Posts: n/a
#2: Sep 23 '08

re: Create limited time download link


Bob Bedford wrote:
Quote:
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 time.
>
The second may help me to know if an image has been downloaded and how many
times.
>
How to build such download link ?
The informations I'd like is the userid, the datetime limit and the
imagefile, off course everything must be encrypted enough not to let other
people create new links.
Putting the datetime limit in the link allow me not to save this information
in a database. Arriving in the linked script will automatically check the
datetime limit.
>
I know how to show the picture, that's easy. Now how to make the user
download the image automatically ? not showing the image but instead making
him to "download" the file.
>
Thanks for advising me about this.
>
Bob
>
>
Put it in a zip file?
Jerry Stuckle
Guest
 
Posts: n/a
#3: Sep 23 '08

re: Create limited time download link


Bob Bedford wrote:
Quote:
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 time.
>
The second may help me to know if an image has been downloaded and how many
times.
>
How to build such download link ?
The informations I'd like is the userid, the datetime limit and the
imagefile, off course everything must be encrypted enough not to let other
people create new links.
Putting the datetime limit in the link allow me not to save this information
in a database. Arriving in the linked script will automatically check the
datetime limit.
>
I know how to show the picture, that's easy. Now how to make the user
download the image automatically ? not showing the image but instead making
him to "download" the file.
>
Thanks for advising me about this.
>
Bob
>
>
>
If they can display the image, they've already downloaded it and can
save it.

However, you can't "make" him download the image - that's up to the
browser settings. All you can do is recommend downloading the picture;

To do that, your script needs to check the time limit, and if it's
within the appropriate headers, i.e.

header('Content-disposition: attachment; filename=image.gif');
header('Content-type: image/gif');
readfile('image.gif');

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Bob Bedford
Guest
 
Posts: n/a
#4: Sep 23 '08

re: Create limited time download link


Put it in a zip file?

Hi R0g,

thanks for your suggestion.

People that use the site may be good enough to follow the procedure to
download images (everything is explained) but some may be unable to "unzip"
files.

Ideally, the script should show the "save as" message and let people save
the file. If I don't use the <IMGtag, the file will be proposed for
saving, isn'it ? or should I use an other way (maybe javascript).

Bob


Bob Bedford
Guest
 
Posts: n/a
#5: Sep 23 '08

re: Create limited time download link


If they can display the image, they've already downloaded it and can save
Quote:
it.
>
However, you can't "make" him download the image - that's up to the
browser settings. All you can do is recommend downloading the picture;
>
To do that, your script needs to check the time limit, and if it's within
the appropriate headers, i.e.
>
header('Content-disposition: attachment; filename=image.gif');
header('Content-type: image/gif');
readfile('image.gif');
>
--
Hi Jerry,

thanks for your suggestion. I've to do a "you can't do simple" way. Most
people don't know how to do a "right click" and then "save as". Also Mac
users don't have a "right" button.
Also I can't ask people to change their settings. Ideally the script should
propose the file as "save as...".

Bob


703designs
Guest
 
Posts: n/a
#6: Sep 23 '08

re: Create limited time download link


Hi Bob,

I think that you'll find this comment helpful: It looks like a pretty
bulletproof way to force a file download, just tweak it to work with
these images rather than .xls files.

http://us2.php.net/manual/en/function.header.php#83384

Thomas

On Sep 23, 1:24*pm, "Bob Bedford" <b...@bedford.comwrote:
Quote:
Quote:
Put it in a zip file?
>
Hi R0g,
>
thanks for your suggestion.
>
People that use the site may be good enough to follow the procedure to
download images (everything is explained) but some may be unable to "unzip"
files.
>
Ideally, the script should show the "save as" message and let people save
the file. If I don't use the <IMGtag, the file will be proposed for
saving, isn'it ? or should I use an other way (maybe javascript).
>
Bob
Jerry Stuckle
Guest
 
Posts: n/a
#7: Sep 23 '08

re: Create limited time download link


Bob Bedford wrote:
Quote:
Quote:
>If they can display the image, they've already downloaded it and can save
>it.
>>
>However, you can't "make" him download the image - that's up to the
>browser settings. All you can do is recommend downloading the picture;
>>
>To do that, your script needs to check the time limit, and if it's within
>the appropriate headers, i.e.
>>
>header('Content-disposition: attachment; filename=image.gif');
>header('Content-type: image/gif');
>readfile('image.gif');
>>
>--
Hi Jerry,
>
thanks for your suggestion. I've to do a "you can't do simple" way. Most
people don't know how to do a "right click" and then "save as". Also Mac
users don't have a "right" button.
Also I can't ask people to change their settings. Ideally the script should
propose the file as "save as...".
>
Bob
>
>
>
The code I gave you is the best you're going to do. You can't force it;
you can only recommend. And that's what the code does.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Bob Bedford
Guest
 
Posts: n/a
#8: Sep 23 '08

re: Create limited time download link


Hi Thomas
Quote:
>"703designs" <thomasmallen@gmail.coma écrit dans le message de news:
>0bba862c-bf7c-4321-8680-8675ef0c627d@k7g2000hsd.googlegroups.com...
>Hi Bob,
>
>I think that you'll find this comment helpful: It looks like a pretty
>bulletproof way to force a file download, just tweak it to work with
>these images rather than .xls files.
>
>http://us2.php.net/manual/en/function.header.php#83384
Great source, this is exactly what I were looking for.

Thanks a lot !

Bob



Bob Bedford
Guest
 
Posts: n/a
#9: Sep 23 '08

re: Create limited time download link


Hi Jerry,
Quote:
The code I gave you is the best you're going to do. You can't force it;
you can only recommend. And that's what the code does.
....and that's why I'm gratefull about your help, that I appreciate a lot.

Thank you.

Bob


Bill H
Guest
 
Posts: n/a
#10: Sep 23 '08

re: Create limited time download link


On Sep 23, 12:47*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
Bob Bedford wrote:
Quote:
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 time.
>
Quote:
The second may help me to know if an image has been downloaded and how many
times.
>
Quote:
How to build such download link ?
The informations I'd like is the userid, the datetime limit and the
imagefile, off course everything must be encrypted enough not to let other
people create new links.
Putting the datetime limit in the link allow me not to save this information
in a database. Arriving in the linked script will automatically check the
datetime limit.
>
Quote:
I know how to show the picture, that's easy. Now how to make the user
download the image automatically ? not showing the image but instead making
him to "download" the file.
>
Quote:
Thanks for advising me about this.
>
Quote:
Bob
>
If they can display the image, they've already downloaded it and can
save it.
>
However, you can't "make" him download the image - that's up to the
browser settings. *All you can do is recommend downloading the picture;
>
To do that, your script needs to check the time limit, and if it's
within the appropriate headers, i.e.
>
header('Content-disposition: attachment; filename=image.gif');
header('Content-type: image/gif');
readfile('image.gif');
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>
- Show quoted text -
Jerry

I just noticed the part about the header, this may resolve an issue I
have been having streaming images out. I want to set the mime type in
the header and also send the size so Flash knows how big it is, but it
would never let me do more than one "content" in the header tag. I
tried seperating them with "\n" like I would do in perl, but now,
after seeing what you posted, it dawned on me that you can use
multiple header()'s instead of combining them into one. Is that so?

Bill H
Jerry Stuckle
Guest
 
Posts: n/a
#11: Sep 23 '08

re: Create limited time download link


Bill H wrote:
Quote:
On Sep 23, 12:47 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>Bob Bedford wrote:
Quote:
>>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 time.
>>The second may help me to know if an image has been downloaded and how many
>>times.
>>How to build such download link ?
>>The informations I'd like is the userid, the datetime limit and the
>>imagefile, off course everything must be encrypted enough not to let other
>>people create new links.
>>Putting the datetime limit in the link allow me not to save this information
>>in a database. Arriving in the linked script will automatically check the
>>datetime limit.
>>I know how to show the picture, that's easy. Now how to make the user
>>download the image automatically ? not showing the image but instead making
>>him to "download" the file.
>>Thanks for advising me about this.
>>Bob
>If they can display the image, they've already downloaded it and can
>save it.
>>
>However, you can't "make" him download the image - that's up to the
>browser settings. All you can do is recommend downloading the picture;
>>
>To do that, your script needs to check the time limit, and if it's
>within the appropriate headers, i.e.
>>
>header('Content-disposition: attachment; filename=image.gif');
>header('Content-type: image/gif');
>readfile('image.gif');
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>>
>- Show quoted text -
>
Jerry
>
I just noticed the part about the header, this may resolve an issue I
have been having streaming images out. I want to set the mime type in
the header and also send the size so Flash knows how big it is, but it
would never let me do more than one "content" in the header tag. I
tried seperating them with "\n" like I would do in perl, but now,
after seeing what you posted, it dawned on me that you can use
multiple header()'s instead of combining them into one. Is that so?
>
Bill H
>
That is correct.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

r0g
Guest
 
Posts: n/a
#12: Sep 23 '08

re: Create limited time download link


Bob Bedford wrote:
Quote:
Quote:
>Put it in a zip file?
>
Hi R0g,
>
thanks for your suggestion.
>
People that use the site may be good enough to follow the procedure to
download images (everything is explained) but some may be unable to "unzip"
files.
>
Ideally, the script should show the "save as" message and let people save
the file. If I don't use the <IMGtag, the file will be proposed for
saving, isn'it ? or should I use an other way (maybe javascript).
>
Bob
>
>
If you send it as a picture type most peoples browsers will just display
it. AFAIK you can't force their browser to offer a save as dialog.
Certainly not with PHP as it is server side only. If you are determined
you may be able to provide your own dialog using client side code but
this would, to the best of my knowledge, require you to embed an activeX
or java program in your site. AFAIK there's no reliable way to do this
with Javascript.

A simple alternative is to use a file type people's browsers won't
automatically open such as zip. Every OS can read zip files natively.
People who may not be aware of what zip is will most likely try to view
the file by double clicking it, thereby launching the OS's zip decompresser.

Even this isn't foolproof though, your clients will probably still get
the option to 'open' it rather than save it and if they do* it will be
opened from the browsers temporary folder and probably lost later.

So you really have 3 choices.

1) Code up some Java to do this (and hope they have Java installed)

2) Try the method I suggested above

3) Possibly the best... Provide verbose and clear instructions on the
download page. If you want to be extra clear then make your script
detect their platform/browser so you can direct them to...

"Right Click - Save Link As" in firefox
"Save link as" in Chrome
"Save target As..." in IE
"Click and hold" on the Mac
etc etc.

Regards,

Roger.

* People will always try what to you may seem like dumb options if you
give them those options! Most people, including those that use computers
every day, aren't computer literate and it's a miracle of UI design they
can and do get by fine anyway :-)
r0g
Guest
 
Posts: n/a
#13: Sep 23 '08

re: Create limited time download link


703designs wrote:
Quote:
Hi Bob,
>
I think that you'll find this comment helpful: It looks like a pretty
bulletproof way to force a file download, just tweak it to work with
these images rather than .xls files.
>
http://us2.php.net/manual/en/function.header.php#83384
>
Thomas
>
On Sep 23, 1:24 pm, "Bob Bedford" <b...@bedford.comwrote:
Quote:
Quote:
>>Put it in a zip file?
>Hi R0g,
>>
>thanks for your suggestion.
>>
>People that use the site may be good enough to follow the procedure to
>download images (everything is explained) but some may be unable to "unzip"
>files.
>>
>Ideally, the script should show the "save as" message and let people save
>the file. If I don't use the <IMGtag, the file will be proposed for
>saving, isn'it ? or should I use an other way (maybe javascript).
>>
>Bob
>

Well I never! Had no idea that was possible... you learn something new
every day on usenet! :-) Bob, please disregard my previous message!

Has anyone tried this yet? Does it work well? For example: does it
trigger Internet Explorer's annoying download auto blocker functionality?


Cool :-)


Roger.
Closed Thread