定制 phpuploader/phpfileuploader 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpuploader/phpfileuploader

最新稳定版本:v1.0.0

Composer 安装命令:

composer require phpuploader/phpfileuploader

包简介

Class to facilitate the process of uploading files using PHP.

README 文档

README

Class to facilitate the process of uploading files using PHP.

Features

  • Upload single or multiple file.
  • Generate random name for the files.
  • Create a custom name for the files.
  • Files verification.

Installation

via composer

composer require phpuploader/phpfileuploader

Simple Example

require ('vendor/autoload.php');

$file = new \PhpFileUploader\Uploader('inputfilename'); // Specify the input file name.
$file->path('/files/'); // Specify the files destination path.
$file->upload(); // move uploaded files (You should call this method at the end).

Generate random name

You can use this method createRandomName() to generate a random name for the files. If you don't call this method the files will be uploaded with their original name.

Example:

$file = new \PhpFileUploader\Uploader('inputfilename');
$file->path('/files/');
$file->createRandomName(); // Generates random name.
$file->upload();

Create custom name

You can use this method createFileName() to create a custom name for the file.

Example:

$file = new \PhpFileUploader\Uploader('inputfilename');
$file->path('/files/');
$file->createFileName('myCustomName'); // Create custom name.
$file->upload();

Check errors

This method displayUploadErrors() will return an array with error messages. The library will verify the files to check whether the file exists, selected or has been uploaded successfully or not.

Upload multiple file

  • Add this attribute multiple="multiple" to the HTML input to allow you select multiple file.
  • Make the input name as array name="files[]". The class will process all the selected files and upload them to the server.

Full Example with HTML form

require ('vendor/autoload.php');

if (isset($_POST['upload'])) 
{
    $file = new \PhpFileUploader\Uploader('myFile'); // Specify the input file name.
    $file->path('/files/'); // Specify the files destination path.
    $file->createRandomName(); // Generate random name.
    $file->upload(); // move uploaded files (You should call this method at the end).

    // Display errors as array
    $file->displayUploadErrors()

    // Check if the files uploaded or not
    if ($file->success()) {
	    // Success
		echo 'Files have been uploaded';
	} else {
		// Failed
	}
}
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST" enctype="multipart/form-data">
	<input type="file" name="myFile[]" multiple="multiple">
	<button type="submit" name="upload">upload</button>
</form>

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固