Pear http_upload File Upload Library

Source: Internet
Author: User
Tags file upload getmessage html form pear

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.

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

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 ()) {        ...     }}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.