473,396 Members | 2,052 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,396 software developers and data experts.

Create limited time download link

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
12 3991
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Martin | last post by:
I have a situation where I'm displaying some information in a table on a web page. I've given the user the ability to make several different "queries" and show different sub-sets of the data. I...
1
by: Sebastian C. | last post by:
Hello everyone I just found at the adress below Microsoft Access Run Time. It says that this is Access Run Time :Alternative Version. There is nothing about who can download or install this...
8
by: Ted Miller | last post by:
Hi folks, I'm looking at moving a large base of C++ code to .Net under tight time constraints. The code runs in mission-critical environments, and I am extremely concerned about the loader lock...
4
by: Asaf | last post by:
Hi, Is there a way to create a temporary download link and to know when the client has finished downloading the file? Thanks in advanced,
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
6
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide...
5
by: nephish | last post by:
Hello there, i have an app that i need to be able to publish a link to download a csv file. i know that i can use php to make the file, but how to i link to it through php. like if i have an...
5
by: moondaddy | last post by:
I want to create a custom UI element which will be a custom rectangle object in a c# XAML application. I'm new to XAML and c# as most of my experience has been using vb with sql. I'm building a...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.