Pear http_upload File Upload Library
Pear's Http_upload class library provides an encapsulated HTML form file upload handler that uses Pear's error system.
Characteristics
Ability to process multiple file uploads at a time
Easy to check file upload status, limit not expected file upload
Multi-lingual error message (no Chinese yet, but can be extended)
Example of a single file upload
Index.htm
PLAIN Textcode: <form action= "./files.php" enctype= "Multipart/form-data" >file 1: <input type= "File" Name= " UserFile "><br><input type=" Submit "name=" Submit "value=" upload! " ></form>files.php
PLAIN textphp: <?phprequire ' http/upload.php '; $upload = new Http_upload (' es ');//Language for error Messages$file = $upload->getfiles (' userfile ');/return a file object or Errorif (Pear::iserror ($file)) { die ($fil E->getmessage ());} Check If the file is a valid Uploadif ($file->isvalid ()) { //This method would return the name of The file you moved, //useful for example to save the name in a DATABASE&NBSP;&N bsp; $file _name = $file->moveto ('./uploads_dir/'); if (PEAR:: IsError ($file _name)) { die ($file _name->getmessage ()); }}?> Multi-File Upload example
PLAIN textcode: <form action= "files.php" enctype= "Multipart/form-data" >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>plain textphp: <?php$files = $upload->getfiles (); Returns an array of file objects or Errorforeach ($files as $file) { if ($file->isvalid ()) { ... }}?>