Create limited time download link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    #1

    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


  • r0g

    #2
    Re: Create limited time download link

    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?

    Comment

    • Jerry Stuckle

      #3
      Re: Create limited time download link

      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.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Bob Bedford

        #4
        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


        Comment

        • Bob Bedford

          #5
          Re: Create limited time download link

          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


          Comment

          • 703designs

            #6
            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.



            Thomas

            On Sep 23, 1:24 pm, "Bob Bedford" <b...@bedford.c omwrote:
            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

            Comment

            • Jerry Stuckle

              #7
              Re: Create limited time download link

              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('Conten t-disposition: attachment; filename=image. gif');
              >header('Conten t-type: image/gif');
              >readfile('imag e.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@attgl obal.net
              =============== ===

              Comment

              • Bob Bedford

                #8
                Re: Create limited time download link

                Hi Thomas
                >"703designs " <thomasmallen@g mail.coma écrit dans le message de news:
                >0bba862c-bf7c-4321-8680-8675ef0c627d@k7 g2000hsd.google groups.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



                Comment

                • Bob Bedford

                  #9
                  Re: Create limited time download link

                  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


                  Comment

                  • Bill H

                    #10
                    Re: Create limited time download link

                    On Sep 23, 12:47 pm, Jerry Stuckle <jstuck...@attg lobal.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...@attgl obal.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

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Create limited time download link

                      Bill H wrote:
                      On Sep 23, 12:47 pm, Jerry Stuckle <jstuck...@attg lobal.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('Conten t-disposition: attachment; filename=image. gif');
                      >header('Conten t-type: image/gif');
                      >readfile('imag e.gif');
                      >>
                      >--
                      >============== ====
                      >Remove the "x" from my email address
                      >Jerry Stuckle
                      >JDS Computer Training Corp.
                      >jstuck...@attg lobal.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@attgl obal.net
                      =============== ===

                      Comment

                      • r0g

                        #12
                        Re: Create limited time download link

                        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 :-)

                        Comment

                        • r0g

                          #13
                          Re: Create limited time download link

                          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.
                          >

                          >
                          Thomas
                          >
                          On Sep 23, 1:24 pm, "Bob Bedford" <b...@bedford.c omwrote:
                          >>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.

                          Comment

                          Working...