Download the PHP package aminyazdanpanah/handling-file-uploads without Composer
On this page you can find all versions of the php package aminyazdanpanah/handling-file-uploads. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package handling-file-uploads
Handling File Uploads
Handles multiple uploads with a powerful validation for images, videos, audios, and archive files. This package allows you to handle your file after your file was uploaded. You can resize, convert, extract and so many things to do after your files were uploaded. At the end, you can extract details of files into an array
.
Features
- Upload multiple files with a configuration variable.
- validate your videos, audios, images, archive files with different rules.
- Manage your files such as converting, resizing, extracting and so many things to do after your files were uploaded.
- Export the details of files into an array and you can easily insert them into a database.
- Compatible with PHP >= 7.1.0.
Installation
This version of the package is only compatible with PHP 7.1.0 and later.
Install the package via composer:
Basic Usage
upload multiple files
upload a single files
Important: Please see examples for more information. In these pages you can see complete examples of usage this package.
Documentation
It is recommended to browse the source code as it is self-documented.
Configuration
In the sever side you should create an array of config and pass it to uploads()
method:
For more information about these attributes, please check the below tables:
Attributes of array of config
attr | default | mean |
---|---|---|
name | mandatory: must be specified | The key name you send your file to the server-PHP($_Files). |
save_to | mandatory: must be specified | The path that you would like to save your file in the server or computer. |
save_as | Base file name | The name that you want to save. |
override | false | Override original file with the same filename. |
validator | no rules | Validate your file before save(see validator table). |
export | Nothing happens | A callback method that you specify additional rules and manage your file after it was uploaded. |
Validation
Before Saving
You can validate your uploaded file before move the uploaded file to the destination. There are some rules that you can apply on your file:
Attributes of validator
attr | default | mean |
---|---|---|
min_size | 1 | The minimum size of files that are allowed (KiloByte). |
max_size | 999999 | The maximum size of files that are allowed (KiloByte). |
types | '*' (everything) | The types that are allowed (must be an array) |
After Saving
You can set some rules after move the uploaded file to the destination by using a callback method. To validate a file after saving, just check your file in the callback method and throw an AYazdanpanah\SaveUploadedFiles\Exception\Exception
. In the end, put it in the array of config and pass it to Upload::files($config)
. In the callback method, you can manage your file. For example, resize image or video, convert video, extracting an archive file and etc. After that, you are able to return your data.
Validate and Manage a Video file
There are some factors that can use to validate a video. I recommended PHP-FFMpeg-video-streaming package that is a wrapper around PHP-FFmpeg. You can validate your video by using its codec, duration, width, height, ratio, and other its attributes. After that, depends on whether your file is valid or not, you can throw an Exception
. At the end, as it can be seen below, you can convert your video or whatever you want to do with your file and export your data:
For more information, please read PHP FFMPEG Video Streaming documentation and php-ffmpeg documentation.
Validate and Manage an image file
To validate and manage an image, I recommended php-image-resize package. For more information I strongly recommand to read php-image-resize documantation . After that, depends on whether your file is valid or not, you can throw an Exception
. At the end, you can export your data:
Validate and Manage an archive file
To validate and manage an archive file, I recommended using UnifiedArchive package. For more information I strongly recommand to read UnifiedArchive documantation . After that, depends on whether your file is valid or not, you can throw an Exception
. At the end, you can export your data:
Validate and Manage an audio file
To validate and manage an archive file, I recommended using php-ffmpeg package. For more information I strongly recommand to read php-ffmpeg . After that, depends on whether your file is valid or not, you can throw an Exception
. At the end, you can export your data:
Exporting Data
After uploading, class return an object that is instance of Filter
. You can export all details of your upload by using all()
method:
Other possible methods
Examples
For see complete example, please go to examples.
Contributing
I'd love your help in improving, correcting, adding to the specification. Please file an issue or submit a pull request.
Please see Contributing File for more information.
Security
If you discover a security vulnerability within this package, please send an e-mail to Amin Yazdanpanah via: contact [AT] aminyazdanpanah • com.
Credits
License
The MIT License (MIT). Please see License File for more information.