Re: Re: HTTP/Upload.php can't handle multiple files!!

From: Date: Thu, 09 Sep 2004 03:00:00 +0000
Subject: Re: Re: HTTP/Upload.php can't handle multiple files!!
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14467@lists.php.net to get a copy of this message
Sir, i got this debug screen. Array ( [userfile] => Array ( [name] => Array ( [0] => Start_with_XML.pdf [1] => vim_doc_a4m.pdf [2] => xml_Chapter_7.pdf ) [type] => Array ( [0] => application/pdf [1] => [2] => ) [tmp_name] => Array ( [0] => /var/tmp/phpJX6PBz [1] => [2] => ) [error] => Array ( [0] => 0 [1] => 2 [2] => 2 ) [size] => Array ( [0] => 81882 [1] => 0 [2] => 0 ) ) ) Fatal error: Call to a member function on a non-object in /www/development/httpupload/upload_02_multiple.php on line 38 and my example code follows.. ## <html><body> <form action="<?php echo $_SERVER['PHP_SELF'];?>?submit=1" method="post" enctype="multipart/form-data"> Send these file:<br> <input type="hidden" name="MAX_FILE_SIZE" value="100000"> Image 1: <input type="file" name="userfile[]"><br> Image 2: <input type="file" name="userfile[]"><br> Image 3: <input type="file" name="userfile[]"><br> <input type="submit" name="sub" value="Upload!"> </form> </body></html> <?php error_reporting(E_ALL); if (!isset($submit)) { exit; } require 'HTTP/Upload.php'; echo '<pre>'; print_r($HTTP_POST_FILES); $upload = new http_upload('en'); //$file = $upload->getFiles('userfile'); $files = $upload->getFiles('userfile[]'); // returns an array of file objects or error if (PEAR::isError($files)) { die ($files->getMessage()); } foreach ($files as $file) { if ($file->isValid()) { $file->setName('uniq'); $dest_dir = './uploads/'; $dest_name = $file->moveTo($dest_dir); if (PEAR::isError($dest_name)) { die ($dest_name->getMessage()); } $real = $file->getProp('real'); echo "Uploaded $real as $dest_name in $dest_dir\n"; }/* elseif ($file->isMissing()) { echo "No file selected\n"; } elseif ($file->isError()) { echo $file->errorMsg() . "\n"; }*/ } // end foreach print_r($file); //print_r($file->getProp()); echo '</pre>'; ?> ## I actually tried the multiple files example on the tar file, but it also did not work. i know im missing something here, but im not sure where. -- Louie Miranda http://www.axishift.com

« previous php.pear.general (#14467) next »