PHP code example of struktal / struktal-file-uploads
1. Go to this page and download the library: Download struktal/struktal-file-uploads 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/ */
struktal / struktal-file-uploads example snippets
$fileUpload = new FileUpload();
// File Upload Options
$fileUpload->setInputName("fileInputName") // Set the Name of the File Input
->setMultiple(false) // Only allow a single File
->setAllowedMimeTypes(["image/jpeg", "image/png"]) // Only allow JPEG and PNG Files
->setMaxSize(2) // Only allow Files up to 2 MiB
->handleUploadedFiles();
// Check if there were Errors during the Upload
if(!($fileUpload->successful())) {
$errors = $fileUpload->getErrors();
return;
}
// Get the uploaded File
$uploadedFile = $fileUpload->getFiles();
$fileUpload = new FileUpload();
// File Upload Options
$fileUpload->setInputName("fileInputName") // Set the Name of the File Input
->setMultiple(true) // Allow multiple Files
->setAllowedMimeTypes(["image/jpeg", "image/png"]) // Only allow JPEG and PNG Files
->setMaxSize(2) // Only allow Files up to 2 MiB
->handleUploadedFiles();
// Check if there were Errors during the Upload
if(!($fileUpload->successful())) {
$errors = $fileUpload->getErrors();
return;
}
// Get the uploaded Files
$uploadedFiles = $fileUpload->getFiles();