Refresh after upload

Last post 07-20-2010, 3:41 AM by Pachanka. 4 replies.
Sort Posts: Previous Next
  •  06-28-2010, 8:15 AM 62044

    Refresh after upload

    plop :)
     
    After an upload (multi-files) the page seems to be reloaded
    but in fact the page is not refreshed ?
    On my page i list files in a directory, afetr upload i see same files.
    If i do F5 i see new files
     
    an idea ?
     
    thanks :)

    Geexor : The space geek
  •  07-05-2010, 2:18 AM 62281 in reply to 62279

    Re: Refresh after upload

  •  07-05-2010, 10:44 AM 62296 in reply to 62281

    Re: Refresh after upload

    Please test the following code and check whether it is what you need,
     <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <title>
      Form - Keeping state after submitting
     </title>
     <link href="demo.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
     <div class="demo">
       
       <h2>Keeping state after submitting</h2>
       <p>A sample demonstrates how to keep uploaded file state during page postbacks.</p>

       <!-- do not need enctype="multipart/form-data" -->
       <form id="form1" method="POST">
        <?php

        $uploader=new PhpUploader();
        $uploader->MaxSizeKB=10240;
        $uploader->MultipleFilesUpload=true;
        $uploader->Name="myuploader";
        $uploader->InsertText="Select multiple files (Max 10M)";
        $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif,*.bmp,*.txt,*.zip,*.rar"; 
        $uploader->Render();

        ?>
        
        <br/><br/><br/>
        
    <?php

    $files=array();

    $processedlist=@$_POST["processedlist"];
    if($processedlist)
    {
     $guidlist=explode("/",$processedlist);
     foreach($guidlist as $fileguid)
     {
      $mvcfile=$uploader->GetUploadedFile($fileguid);
      if($mvcfile)
      {
       array_push($files,$mvcfile);
      }
     }
    }
    $fileguidlist=@$_POST["myuploader"];
    if($fileguidlist)
    {
     $guidlist=explode("/",$fileguidlist);
     foreach($guidlist as $fileguid)
     {
      $mvcfile=$uploader->GetUploadedFile($fileguid);
      if($mvcfile)
      {
       //Process the file here..
       //rename(..)
       
       if($processedlist)
        $processedlist= $processedlist . "/" . $fileguid;
       else
        $processedlist= $fileguid;
      
       array_push($files,$mvcfile);
      }
     }
    }

    if(count($files)>0)
    {
     echo("<table style='border-collapse: collapse' class='Grid' border='0' cellspacing='0' cellpadding='2'>");
     foreach($files as $mvcfile)
     {
      echo("<tr>");
      echo("<td>");echo("<img src='phpuploader/resources/circle.png' border='0' />");echo("</td>");
      echo("<td>");echo($mvcfile->FileName);echo("</td>");
      echo("<td>");echo($mvcfile->FileSize);echo("</td>");
      echo("</tr>");
      
      //Moves the uploaded file to a new location.
      //$mvcfile->MoveTo("/uploads");
      //Copys the uploaded file to a new location.
      //$mvcfile->CopyTo("/uploads");
      //Deletes this instance.
      //$mvcfile->Delete();
     }
     echo("</table>");
    }

    ?>

        <input type='hidden' name='processedlist' value='<?php echo($processedlist) ?>' />

        <br /><br />
        <input type='submit' value="Submit Form" />
        Now: <?php echo(date("H:i:s",time())) ?>
        
       </form>
       
        
     </div>
    </body>
    </html>

    Regards,
     
    Eric
  •  07-20-2010, 3:16 AM 62588 in reply to 62296

    Re: Refresh after upload

    The problem is that the page is not refreshed like a F5 in the browser.
     I' ve tried with a session variable to see that. I putted it to 0 at index.php of program and putted at 1 near the move uploaded file.
    After upload, i see the variable is still at 0 if i do F5 i see 1
     
    i really need your help, i spent 3 days on this problem :/
    thanks
     
     

    Geexor : The space geek
  •  07-20-2010, 3:41 AM 62589 in reply to 62588

    Re: Refresh after upload

    I've found !!!!!!!!!!!!!!!!!!!!!!!
     
    Need to be at start of page, if i come from a post method on a form, page is refreshed :)
     
    <?php
    if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
        header('location:'.$_SERVER['PHP_SELF']);
    }
    ?>
     
    Thanks to me :)
     
     
     

    Geexor : The space geek
View as RSS news feed in XML