PHP code example of programster / upload-file-manager
1. Go to this page and download the library: Download programster/upload-file-manager 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/ */
programster / upload-file-manager example snippets
$uploadManager = new Programster\UploadFileManager\UploadFileManager();
$files = $uploadManager->getUploadFiles();
if (count($files) > 0)
{
/* @var $file Programster\UploadFileManager\UploadFile */
$uploadFile = $files['my_file_input_field_name'];
if ($uploadFile->hasError())
{
throw $file->getException();
}
else
{
// Upload was successful, do something with the file here.
$uploadFile->getFilepath();
$uploadFile->getSize();
$uploadFile->getName();
$uploadFile->getMimeType();
}
}
$uploadManager = new Programster\UploadFileManager\UploadFileManager();
$files = $uploadManager->getUploadFiles();
if (count($files) > 0)
{
// some files were uploaded, loop thorugh them.
foreach ($files as $inputFieldName => $file)
{
/* @var $file Programster\UploadFileManager\UploadFile */
if ($file->hasError())
{
throw $file->getException();
}
else
{
// Upload was successful, do something with the file here.
$uploadFile->getFilepath();
$uploadFile->getSize();
$uploadFile->getName();
$uploadFile->getMimeType();
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.