PHP File Upload class (this class supports uploading of one or more files) (1/2)

Source: Internet
Author: User
Tags php file upload

PHP File Upload class (this class supports uploading one or more files)/*** Class Name: upfile * function: processing file uploads * description, this class processes uploading of one or more files, when using this class, you only need to list this class * For example:

/Php tutorial File Upload class (this class supports uploading of one or more files)
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<Html xmlns = "http://www.bkjia.com/1999/xhtml">
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>

<Body>
<? Php
// PHP File Upload class (this class supports uploading of one or more files)
/**
* Class Name: upfile
* Function: Process file uploads.
* Description: This class processes upload of one or more files. When using this class, you only need to list this class
* Example:
* $ Up = upfile ()
* $ Up-> update_file ($ _ file ['filename'])
*
* $ Up-> update_file function returns an array. Multi-dimensional data is returned if multiple files are uploaded.
* Array content:
* $ Fileinfo ['file _ size'] size of the uploaded file
* $ Fileinfo ['file _ suffix '] file Upload type
* $ Fileinfo ['file _ name'] name of the uploaded file
* $ Fileinfo ['error'] File Upload error
*

*/
Class upfile {
Public $ fcount = 1; // Number of uploaded files
Public $ ftype = array ('jpg ', 'jpeg', 'gif', 'png '); // File Format
Public $ fsize = 1024; // file size unit: kb
Public $ fdir = 'www .bkjia.com/'; // file storage directory
Public $ errormsg = ''; // generated temporary error message

/**
* Function name: get_tmp_file ($ putfile)
* Function: Get the temporary file name for upload.
* @ Param array $ putfile
* @ Return string $ upimg returns the temporary file name
*/
Function get_tmp_file ($ putfile ){
If ($ this-> fcount = 1 ){
$ Tmpfile = $ putfile ['tmp _ name'];
} Else {
For ($ I = 0; $ I <$ this-> fcount; $ I ++ ){
$ Tmpfile [] = $ putfile ['tmp _ name'] [$ I];
}
}
Return $ tmpfile;
} 1 2

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.