Pear: HTTP_Upload introduction. The HTTP_Upload class library of Pear provides an encapsulated html form file Upload handler that uses the Pear error system. This feature allows you to easily verify the upload of multiple files at a time.
The HTTP_Upload class library of Pear provides an encapsulated html form file Upload handler that uses the Pear error system.
Features
Ability to process multiple files at a time
It is easy to verify the upload status of files and restrict the upload of unwanted files.
Multilingual error message (no Chinese characters yet, but can be expanded)
Example of uploading a single file
Index.htm
PLAIN TEXT
CODE:
Files. php
PLAIN TEXT
PHP:
RequireHTTP/Upload. php;
$ Upload = newHTTP_Upload (es );
// Language for error messages
$ File = $ upload-> getFiles (userfile );
// Return a file object or error
If (PEAR: isError ($ file )){
Die ($ file-> getMessage ());
}
// Check if the file is a valid upload
If ($ file-> isValid () {// this method will return the name of the file you moved,
// Useful for example to save the name in a database
$ File_name = $ file-> moveTo (./uploads_dir /);
If (PEAR: isError ($ file_name )){
Die ($ file_name-> getMessage ());
}
}
?>
Multifile Upload example
PLAIN TEXT
CODE:
PLAIN TEXT
PHP:
$ Files = $ upload-> getFiles (); // returns an array of file objects or error
Foreach ($ filesas $ file ){
If ($ file-> isValid ()){
...
}
}?>
Download
Http://pear.php.net/package/HTTP_Upload
Copyright disclaimer: you can reprint the document at will. during reprinting, you must mark the original source and author information of the article as hyperlinks and this statement.
Published by volcano on September 16, 2006 at am
Copyright information: This information can be reproduced at will. during reprinting, you must mark the original source and author information of the article in the form of hyperlinks and this statement.
Permanent link-http://www.ooso.net/index.php/archives/240
Bytes. It is easy to verify the upload of multiple files at a time...