erykai/upload

Upload media, files and images

Maintainers

Details

github.com/Erykai/upload

Source

Issues

Fund package maintenance!
Erykai

v1.4.2 2022-11-17 11:57 UTC

This package is auto-updated.

Last update: 2024-12-19 15:59:27 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Quality Score Total Downloads

Upload media, files, images and upload url

Video Documentation

Installation

Composer:

"erykai/upload": "1.2.*"

Terminal

composer require erykai/upload

Create config.php

//define name folder uploads system
const UPLOAD_DIR = 'storage';
//define mimetypes accepts
const UPLOAD_MIMETYPE = [
    'image/jpeg',
    'image/gif',
    'image/png',
    'image/svg+xml',
    'audio/mpeg',
    'video/mp4',
    'application/msword',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/pdf'
];

Upload $_FILES

require "config.php";
require "vendor/autoload.php";

use Erykai\Upload\Upload;
$upload = new Upload();
$upload->save();
print_r($upload->response());

Upload $_POST url

require "config.php";
require "vendor/autoload.php";

use Erykai\Upload\Upload;
$upload = new Upload($_POST['cover'], 'cover');
$upload->save();
print_r($upload->response());

Upload url

require "config.php";
require "vendor/autoload.php";

use Erykai\Upload\Upload;
$upload = new Upload('https://web.com/pdf.pdf', 'document');
$upload->save();
print_r($upload->response());

Create object and delete

if($upload->save()){
        $user = new stdClass();
            foreach ($upload->response()->data as $key => $value) {
                $user->$key = $value;
                $file = true;
            }
        }   
        //case delete
        if($file){
           $upload->delete();
           print_r($upload->response());
        }

Delete image

$upload->delete("storage/image/2022/08/10/imagem.jpg");
print_r($upload->response());

Contribution

All contributions will be analyzed, if you make more than one change, make the commit one by one.

Support

If you find faults send an email reporting to webav.com.br@gmail.com.

Credits

License

The MIT License (MIT). Please see License for more information.