Home PHP Libraries Other libraries PHP class to add watermark, date, thumbnail to multi-file upload
PHP class to add watermark, date, thumbnail to multi-file upload
<?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.

Disclaimer

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

How Does jQuery Simplify DOM Manipulation for Web Developers? How Does jQuery Simplify DOM Manipulation for Web Developers?

03 Jan 2025

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

How to Execute Command Line Binaries in Node.js? How to Execute Command Line Binaries in Node.js?

27 Dec 2024

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

Manage duplicates in your Bitwarden Vault with Python Manage duplicates in your Bitwarden Vault with Python

05 Jan 2025

Bitwarden doesn't have a built-in method for managing duplicates in your vault. I wasn't happy with the other user-made libraries I found, so I went and created a Python-based tool to help automate the process. Features Filter entries by

How to Integrate External Libraries into IntelliJ IDEA Artifacts? How to Integrate External Libraries into IntelliJ IDEA Artifacts?

23 Dec 2024

Incorporating External Libraries into IntelliJ IDEA ArtifactsTo seamlessly integrate external libraries within your IntelliJ IDEA artifacts,...

How Can Libraries Access Configuration Settings Without Using app.config? How Can Libraries Access Configuration Settings Without Using app.config?

01 Jan 2025

Providing Configuration Settings for Libraries: An Alternative to App.configUnlike executable applications, libraries (DLLs) do not have direct...

How Do I Integrate External Libraries, Like Psapi.lib, into My Qt Creator Projects? How Do I Integrate External Libraries, Like Psapi.lib, into My Qt Creator Projects?

26 Dec 2024

Integrating External Libraries into Qt Creator ProjectsAdding external libraries to projects developed using Qt Creator enhances their...

See all articles