HTTP_Upload
[ class tree: HTTP_Upload ] [ index: HTTP_Upload ] [ all elements ]

Source for file upload_example.php

Documentation is available at upload_example.php

  1. <html><body>
  2. <form action="<?php echo $_SERVER['PHP_SELF'];?>?submit=1" method="post" enctype="multipart/form-data">
  3.    Send these files:<br>
  4.   <input type="hidden" name="MAX_FILE_SIZE" value="100000">
  5.    
  6.    <input name="userfile" type="file"> &lt;-<br>
  7.    <input name="otherfile[]" type="file"><br>
  8.    <input name="otherfile[]" type="file"><br>
  9.    <input type="submit" value="Send files">
  10. </form>
  11. </body></html>
  12. <?php
  13. if (!isset($submit)) {
  14.     exit;
  15. }
  16. require 'HTTP/Upload.php';
  17. echo '<pre>';
  18. //print_r($HTTP_POST_FILES);
  19. $upload = new http_upload('es');
  20. $file $upload->getFiles('userfile');
  21. if (PEAR::isError($file)) {
  22.     die ($file->getMessage());
  23. }
  24. if ($file->isValid()) {
  25.     $file->setName('uniq');
  26.     $dest_dir './uploads/';
  27.     $dest_name $file->moveTo($dest_dir);
  28.     if (PEAR::isError($dest_name)) {
  29.         die ($dest_name->getMessage());
  30.     }
  31.     $real $file->getProp('real');
  32.     echo "Uploaded $real as $dest_name in $dest_dir\n";
  33. elseif ($file->isMissing()) {
  34.     echo "No file selected\n";
  35. elseif ($file->isError()) {
  36.     echo $file->errorMsg("\n";
  37. }
  38. print_r($file->getProp());
  39. echo '</pre>';
  40. ?>

Documentation generated on Mon, 11 Mar 2019 13:54:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.