By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Create limited time download link

P: n/a
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
Sep 23 '08 #1
Share this Question
Share on Google+
12 Replies


P: n/a
r0g
Bob Bedford wrote:
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?
Sep 23 '08 #2

P: n/a
Bob Bedford wrote:
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.
js*******@attglobal.net
==================

Sep 23 '08 #3

P: n/a
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
Sep 23 '08 #4

P: n/a
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
Sep 23 '08 #5

P: n/a
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:
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
Sep 23 '08 #6

P: n/a
Bob Bedford wrote:
>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.
js*******@attglobal.net
==================

Sep 23 '08 #7

P: n/a
Hi Thomas
>"703designs" <th**********@gmail.coma écrit dans le message de news:
0b**********************************@k7g2000hsd.g ooglegroups.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

Sep 23 '08 #8

P: n/a
Hi Jerry,
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
Sep 23 '08 #9

P: n/a
On Sep 23, 12:47*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Bob Bedford wrote:
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
Sep 23 '08 #10

P: n/a
Bill H wrote:
On Sep 23, 12:47 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Bob Bedford wrote:
>>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.
js*******@attglobal.net
==================

Sep 23 '08 #11

P: n/a
r0g
Bob Bedford wrote:
>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 :-)
Sep 23 '08 #12

P: n/a
r0g
703designs wrote:
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:
>>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.
Sep 23 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.