Download dialog issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laser
    New Member
    • Nov 2008
    • 3

    Download dialog issue

    Dear friends,
    My download php script is working fine. But i have to record that when the file is actually downloaded in the database. To capture this after the download code ends i am connecting to the database and updating the records. Till here every thing is working according to my code. Even though i click on Open button my database update codes get executed.

    How to restrict this as only on Save button click it must get executed.

    Thanks and regards,
    laser.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    I really have no idea what you're asking.

    Can you give a little bit more detail on what you are doing please?





    Dan

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #3
      If I understand you have a web page that lists files (of some sort) for visitors/members to download.

      When a file is downloaded you wanted that fact stored in a database - either as a new record as an update to a record count. A download dialogue box offers the user to save the file or open the file and you only want the system to update the DB if the user selects to save the file.

      If I understand this correctly I have to ask why selecting open doesn't count as a download? I know the user won't have a local copy but they will have consumed the resource you provide so surely it's worth knowing that?

      I don't know if there is way of telling what the user selected in that dialogue box. If there is I would be very interested as I have a system that works in a similar fashion.

      Cheers
      nathj

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi.

        I do not believe there is a way to detect whether or not the user saved the file, opened it or did whatever else he may be able to do with it.
        Keep in mind that some browsers do not even have a "Save" button. Both Safari and Chrome automatically download files without any dialog. Firefox can also be configure to do this.

        From the server's perspective, all of that is the same thing. It simply sends the file to the browser. What the browser actually does with the file is of no interest to the server.

        Comment

        • laser
          New Member
          • Nov 2008
          • 3

          #5
          Thanks Nathj and Atli,

          Nath you have got it exactly what i wanted.

          It means that even though user selects "Cancel" button under Download dialog box my php script will update the record as downloaded.

          That means if user clicks on the filename hyperlink and download dialog appears, it is understood that the file is downloaded and database can be updated.

          Thanks
          laser.

          Comment

          • nathj
            Recognized Expert Contributor
            • May 2007
            • 937

            #6
            What you have outlined here is the problem I have come across. If a member clicks cancel then the DB is still updated even though they haven't used the resource at all.

            I had decided just to ignore this fact and simply work on a % of usage being accurate. If anyone does know of a way of detecting 'cancel' then that would be brilliant but I fear Atli is spot on - there is no way of knowing what the user clicks.

            Cheers
            nathj

            Comment

            • laser
              New Member
              • Nov 2008
              • 3

              #7
              Thanks alot "Nathj" for your your comments and time spent on this.

              Regards,
              laser.

              Comment

              Working...