php 文件上传类与实例
本文分享一个不错的
php 文件上传,可以实现单个文件的上传、多个文件的上传功能。有需
要的朋友参考下吧。
1,php 文件上传类
<?php
/**
* php 文件上传类
* by www.jbxue.com
*/
class file_upload {
var $the_file;
var $the_temp_file;
var $upload_dir;
var $replace;
var $do_filename_check;
var $max_length_filename = 100;
var $extensions;
var $ext_string;
var $language;
var $http_error;
var $rename_file; // if this var is true the file copy get a new name
var $file_copy; // the new name
var $message = array();
var $create_directory = true;
function file_upload() {
$this->language = "en"; // choice of en, nl, es
$this->rename_file = false;
$this->ext_string = "";
}
function show_error_string() {
$msg_string = "";
foreach ($this->message as $value) {
$msg_string .= $value."<br>\n";
}
return $msg_string;
}
function set_file_name($new_name = "") { // this "conversion" is used for unique/new filenames
if ($this->rename_file) {
if ($this->the_file == "") return;
$name = ($new_name == "") ? strtotime("now") : $new_name;
$name = $name.$this->get_extension($this->the_file);
} else {