file_uploader
1.0.0
PHP 파일 업 로더 패키지
현재 버전 : [v1.0.2]
작곡가를 통해
$ composer require clivern/file_uploader먼저 업 로더 클래스를 구성합니다.
include_once dirname ( __FILE__ ) . ' /vendor/autoload.php ' ;
$ uploader = new Clivern FileUploader Uploader ([
' dir_path ' => dirname ( __FILE__ ), # Path to storage directory
' dir_name ' => ' storage ' , # Storage directory name
' year_storage_based ' => true , # Whether to arrange uploaded file in year directories
' month_storage_based ' => true , # Whether to arrange uploaded file in months under year directories
]);그런 다음 파일을 업로드하고 확인하십시오
$ result = $ uploader -> uploadFile ( ' test ' , [ # test is the file input name
# validate allowed extensions
# Possible values are:
# false => to stop extension validation.
# array of allowed extensions.
' supported_extensions ' => [ ' txt ' ],
# validate allowed types
# Possible values are:
# false => to stop type validation.
# array of allowed types.
' supported_types ' => [ ' text/plain ' ],
# Maximum upload size
# Possible values are:
# false => to stop size validation.
# 1KB or 2KB or 8KB and so on.
# 2MB or 3MB or 8MB and so on.
# 3GB or 4GB or 5GB and so on.
# 4TP or 8TP or 10TP and so on.
# 9PB or 8PB and so on.
' max_size ' => ' 2MB ' ,
]);그런 다음 파일 업로드가 있는지 확인하십시오
if (! $ result ) {
# Get Errors List
$ errors = $ uploader -> getErrors ();
} else {
# Get uploaded file info
$ file_info = $ uploader -> getFileInfo ();
}이 작업 예제를 탐색하십시오
<?php
include_once dirname ( __FILE__ ) . ' /vendor/autoload.php ' ;
if ( isset ( $ _FILES [ ' test ' ]) ){
$ uploader = new Clivern FileUploader Uploader ([
' dir_path ' => dirname ( __FILE__ ), # Path to storage directory
' dir_name ' => ' storage ' , # Storage directory name
' year_storage_based ' => true , # Whether to arrange uploaded file in year directories
' month_storage_based ' => true , # Whether to arrange uploaded file in months under year directories
]);
$ result = $ uploader -> uploadFile ( ' test ' , [ # test is the file input name
# validate allowed extensions
# Possible values are:
# false => to stop extension validation.
# array of allowed extensions.
' supported_extensions ' => [ ' txt ' ],
# validate allowed types
# Possible values are:
# false => to stop type validation.
# array of allowed types.
' supported_types ' => [ ' text/plain ' ],
# Maximum upload size
# Possible values are:
# false => to stop size validation.
# 1KB or 2KB or 8KB and so on.
# 2MB or 3MB or 8MB and so on.
# 3GB or 4GB or 5GB and so on.
# 4TP or 8TP or 10TP and so on.
# 9PB or 8PB and so on.
' max_size ' => ' 2MB ' ,
]);
echo ' <pre> ' ;
if (! $ result ) {
# Get Errors List
$ errors = $ uploader -> getErrors ();
var_dump ( $ errors );
} else {
# Get uploaded file info
$ file_info = $ uploader -> getFileInfo ();
var_dump ( $ file_info );
}
die ();
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="test" />
<input type="submit"/>
</form> Version 1.0.2
> Initial Release
$ composer test 자세한 내용은 기여 및 행동을 참조하십시오.
보안 관련 문제를 발견하면 문제 추적기를 사용하는 대신 [email protected]으로 이메일을 보내주십시오.
MIT 라이센스 (MIT). 자세한 내용은 라이센스 파일을 참조하십시오.