home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / uploader_default1.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.4 KB  |  99 lines

  1. <?php
  2. /**
  3.  * Standard Default Upload ProgressBar example.
  4.  *
  5.  * @version    $Id: uploader_default1.php,v 1.1 2004/02/14 22:07:25 farell Exp $
  6.  * @author     Laurent Laville <pear@laurent-laville.org>
  7.  * @package    HTML_Progress
  8.  */
  9.  
  10. require_once 'HTML/Progress/uploader.php';
  11.  
  12. // Account FTP on remote server
  13. $ftp = array(
  14.     'user' => 'farell',
  15.     'pass' => 'xxxxxx',
  16.     'host' => 'ftpperso.free.fr'
  17. );
  18.  
  19. // A standard progress uploader dialog box 
  20. $uploader = new HTML_Progress_Uploader();
  21.  
  22. // Allow only pictures upload
  23. $uploader->setValidExtensions(array('gif','jpg','jpeg','png'));
  24. ?>
  25. <!DOCTYPE html
  26.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  27.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  28.  
  29. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  30. <head>
  31. <title>Web-FTP Uploader with ProgressBar - Default renderer </title>
  32. <style type="text/css">
  33. <!--
  34. .progressStatus {
  35.     color:#000000; 
  36.     font-size:10px;
  37. }
  38. <?php echo $uploader->getStyle(); ?>
  39. // -->
  40. </style>
  41. <script type="text/javascript">
  42. <!--
  43. <?php echo $uploader->getScript(); ?>
  44. //-->
  45. </script>
  46. </head>
  47. <body>
  48.  
  49. <?php 
  50. // Display progress uploader dialog box
  51. echo $uploader->toHtml();
  52.  
  53.  
  54. if ($uploader->isStarted()) {
  55. // Begin upload
  56.  
  57.     // declare files to upload    
  58.     $uploader->setFiles(array(
  59.         'splintercell.jpg',
  60.         'd:/Mes Documents/Mes images/black hawk down/00010484.jpg',
  61.         'monitor.html'       // NOTE: invalid file extension, won't be uploaded
  62.         )
  63.     );
  64.  
  65.     // connect to ftp server
  66.     $logs = $uploader->logon($ftp['user'], $ftp['pass'], $ftp['host']);
  67.     if (PEAR::isError($logs)) {
  68.         die($logs->getMessage());
  69.     }    
  70.  
  71.     // set timeout as a default ftp connection
  72.     set_time_limit(90);
  73.  
  74.     $ret = $uploader->moveTo('tmp', false);  // do not replace existing files (default)
  75.     if (PEAR::isError($ret)) {
  76.         die($ret->getMessage());
  77.     }    
  78.  
  79.     // summary of uploads operation
  80.     if (count($ret) == 0) {
  81.         echo '<i>All files were move on to ' . $ftp['host'] . "</i><br/>\n";
  82.     } else {
  83.         echo '<b>Some files were not move on to ' . $ftp['host'] . "</b><br/>\n";
  84.         print "<pre>";
  85.         var_dump($ret);
  86.         print "</pre>";
  87.     }
  88.  
  89.     // disconnect from ftp server
  90.     $uploader->logoff();
  91. }
  92.  
  93. if ($uploader->isCanceled()) {
  94.     $uploader->logoff();     // disconnect from ftp server before a timeout has occured
  95. }
  96. ?>
  97.  
  98. </body>
  99. </html>