Re: Renaming File

  •  08-26-2010, 10:32 AM

    Re: Renaming File

    You are using multiple files upload, please try the following code:
    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <html>
    <body>
    <form id="form1" method="POST"><?php   
    $uploader=new PhpUploader();
    $uploader->Name="myuploader";
    $uploader->MultipleFilesUpload=true;
    $uploader->Render();
    ?>
    </form>
    <?php
    $fileguidlist=@$_POST["myuploader"];
    if($fileguidlist)
    {
     $guidlist=explode("/",$fileguidlist);
     echo("<div style='font-family:Fixedsys;'>");
     echo("Uploaded ");
     echo(count($guidlist));
     echo(" files:");
     echo("</div>");
     echo("<hr/>");
     foreach($guidlist as $fileguid)
     {
      $mvcfile=$uploader->GetUploadedFile($fileguid);
      if($mvcfile)
      {
       echo("<div style='font-family:Fixedsys;border-bottom:dashed 1px gray;padding:6px;'>");
       echo("FileName: ");
       echo($mvcfile->FileName);
       echo("<br/>FileSize: ");
       echo($mvcfile->FileSize." b");
       //  echo("<br/>FilePath: ");
       //  echo($mvcfile->FilePath);
       echo("</div>");
       $filename = str_replace(' ', '_', $mvcfile->FileName); 
       echo "eric1"; 
       $uploadpath="z:/temp/";   //please replace path to your actual path
       $targetfilepath = $uploadpath . $filename;
       if( is_file ($targetfilepath) )
       unlink($targetfilepath);
       $mvcfile->CopyTo( $targetfilepath );   
       $mvcfile->Delete();
      }
     }
    }
    ?>
    </body>
    </html>
    Regards,
    Eric
View Complete Thread