<?php class upload { var $dir; //附件存放物理目录 var $time; //自定义文件上传时间 var $allow_types; //允许上传附件类型 var $field; //上传控件名称 var $maxsize; //最大允许文件大小,单位为KB var $thumb_width; //缩略图宽度 var $thumb_height; //缩略图高度 var $watermark_file; //水印图片地址 var $watermark_pos; //水印位置 var $watermark_trans;//水印透明度 //构造函数 //$types : 允许上传的文件类型 , $maxsize : 允许大小 , $field : 上传控件名称 , $time : 自定义上传时间 function upload($types = 'jpg|png', $maxsize = 1024, $field = 'attach', $time = '') { $this->allow_types = explode('|',$types); $this->maxsize = $maxsize * 1024; $this->field = $field; $this->time = $time ? $time : time(); } //设置并创建文件具体存放的目录 //$basedir : 基目录,必须为物理路径 //$filedir : 自定义子目录,可用参数{y}、{m}、{d} function set_dir($basedir,$filedir = '') { $dir = $basedir; !is_dir($dir) && @mkdir($dir,0777); if (!empty($filedir)) { $filedir = str_replace(array('{y}','{m}','{d}'),array(date('Y',$this->time),date('m',$this->time),date('d',$this->time)),strtolower($filedir));//用string_replace把{y} {m} {d}几个标签进行替换 $dirs = explode('/',$filedir); foreach ($dirs as $d) { !empty($d) && $dir .= $d.'/'; !is_dir($dir) && @mkdir($dir,0777); } } $th
PHP multi-file upload class that supports watermarks, dates, and thumbnails. Set and create the directory where the files are stored. Picture thumbnail settings. If thumbnails are not generated, no settings are needed. Picture watermark settings. If no watermarks are generated, add watermarks. There is no need to set it, file upload is performed, and after processing, an array of file information containing successful or failed upload is returned.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article

13Dec2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

28Oct2024
Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

03Jan2025
Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...

30Oct2024
Native Java Image Processing Libraries for High-Quality ResultsAs you have encountered limitations with ImageMagick and JAI, let's explore other...

27Dec2024
Executing Command Line Binaries in Node.jsExecuting third-party binaries is an essential task when porting CLI libraries from other languages to...

24Oct2024
This article guides developers on crafting static libraries in C using g . It demonstrates how to compile source code into object files, create static libraries, and incorporate them into other projects. By leveraging this approach, developers can


Hot Tools

PHP library for dependency injection containers
PHP library for dependency injection containers

A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking

Small PHP library for optimizing images
Small PHP library for optimizing images
