PHP code example of erykai / upload
1. Go to this page and download the library: Download erykai/upload library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
erykai / upload example snippets
//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'
];
use Erykai\Upload\Upload;
$upload = new Upload();
$upload->save();
print_r($upload->response());
use Erykai\Upload\Upload;
$upload = new Upload($_POST['cover'], 'cover');
$upload->save();
print_r($upload->response());
use Erykai\Upload\Upload;
$upload = new Upload('https://web.com/pdf.pdf', 'document');
$upload->save();
print_r($upload->response());
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());
}
$upload->delete("storage/image/2022/08/10/imagem.jpg");
print_r($upload->response());