PHP File Upload

Source: Internet
Author: User
Tags php file upload

<?php      //包含一个文件上传类中的上传类      include "fileupload.class.php" ;        $up = new fileupload;      //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)      $up -> set( "path" , "./images/" );      $up -> set( "maxsize" , 2000000);      $up -> set( "allowtype" , array ( "gif" , "png" , "jpg" , "jpeg" ));      $up -> set( "israndname" , false);        //使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false      if ( $up -> upload( "pic" )) {          echo ‘<pre>‘ ;          //获取上传后文件名子          var_dump( $up ->getFileName());          echo ‘</pre>‘ ;        } else {          echo ‘<pre>‘ ;          //获取上传失败以后的错误提示          var_dump( $up ->getErrorMsg());          echo ‘</pre>‘ ;      } ?>

PHP File Upload

Related Article

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: info-contact@alibabacloud.com 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.