refresh

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stijn Goris

    refresh

    hi all,

    Is there a way to prevent a refresh of a page?
    When a user refreshen on a certain page, pictures he already uploaded, will
    upload again...

    regards
    Stijn


  • Chip

    #2
    Re: refresh

    Stijn Goris wrote:[color=blue]
    > hi all,
    >
    > Is there a way to prevent a refresh of a page?
    > When a user refreshen on a certain page, pictures he already uploaded, will
    > upload again...
    >
    > regards
    > Stijn
    >
    >[/color]
    Do you mean downloaded or uploaded? Downloading is usually handled by
    the browser cache settings and images aren't actually downloaded a
    second time.

    Comment

    • Shawn Wilson

      #3
      Re: refresh

      Stijn Goris wrote:[color=blue]
      >
      > Is there a way to prevent a refresh of a page?
      > When a user refreshen on a certain page, pictures he already uploaded, will
      > upload again...[/color]

      You could do something like this in your form:

      <input type="hidden" name="uniqueid" value="<?PHP echo uniqid(); ?>">

      And in your handling code, put something like this:

      $file = file("logfile.t xt");

      //if form has been sent, make the user obtain a new unique id
      if (in_array($_POS T['uniqueid'], $file)):
      echo 'The form has already been sent. Click <a href="foo.php"> here</a> to
      send again.';

      else:
      //Process your file uploads as you do now.

      //write unique id to logfile
      if ($logfile = fopen("logfile. txt", "a")) {
      fwrite($logfile , $_POST['uniqueid']);
      fclose($logfile );
      }

      endif;

      You'd have to periodically clean out the logfile. You could also use a database
      table to do this.

      Regards,
      Shawn
      --
      Shawn Wilson
      shawn@glassgian t.com

      Comment

      • Shawn Wilson

        #4
        Re: refresh


        Shawn Wilson wrote:[color=blue]
        >
        > Stijn Goris wrote:[color=green]
        > >
        > > Is there a way to prevent a refresh of a page?
        > > When a user refreshen on a certain page, pictures he already uploaded, will
        > > upload again...[/color]
        >
        > You could do something like this in your form:
        >
        > <input type="hidden" name="uniqueid" value="<?PHP echo uniqid(); ?>">
        >
        > And in your handling code, put something like this:
        >
        > $file = file("logfile.t xt");
        >
        > //if form has been sent, make the user obtain a new unique id
        > if (in_array($_POS T['uniqueid'], $file)):
        > echo 'The form has already been sent. Click <a href="foo.php"> here</a> to
        > send again.';
        >
        > else:
        > //Process your file uploads as you do now.
        >
        > //write unique id to logfile
        > if ($logfile = fopen("logfile. txt", "a")) {
        > fwrite($logfile , $_POST['uniqueid']);
        > fclose($logfile );
        > }
        >
        > endif;
        >
        > You'd have to periodically clean out the logfile. You could also use a database
        > table to do this.[/color]

        Or, if you prefer an example that has a chance of working, try this line
        instead:

        fwrite($logfile , $_POST['uniqueid']."\n");

        Regards,
        Shawn
        --
        Shawn Wilson
        shawn@glassgian t.com

        Comment

        • CountScubula

          #5
          Re: refresh

          http://www.gzentools.com -- free online php tools
          "Stijn Goris" <mepisto@hotmai l.com> wrote in message
          news:bdK%b.1524 9$I%5.733312@ph obos.telenet-ops.be...[color=blue]
          > hi all,
          >
          > Is there a way to prevent a refresh of a page?
          > When a user refreshen on a certain page, pictures he already uploaded,[/color]
          will[color=blue]
          > upload again...
          >
          > regards
          > Stijn
          >
          >[/color]

          I take it at the moment you have 2 parts, 1-an upload form, 2-upload
          script/page, change this to 3 parts,
          1-upload form, 2-upload script, 3-page.
          At the end of you upload script, redirtect to the destination page with this

          <?php
          // code to handle file upload

          header("Locatio n: http://www.yourdomain. com/nextpage.php");
          ?>

          then if they refresh next page, it will not upload again.

          --
          Mike Bradley



          Comment

          Working...