1. Go to this page and download the library: Download popphp/pop-file 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/ */
popphp / pop-file example snippets
use Pop\File\Upload;
$upload = new Upload('/path/to/uploads');
$upload->useDefaults();
$upload->upload($_FILES['file_upload']);
// Do something with the newly uploaded file
if ($upload->isSuccess()) {
$file = $upload->getUploadedFile();
} else {
echo $upload->getErrorMessage();
}
$filename = $upload->checkFilename('my-custom-filename.docx');
// $filename is set to 'my-custom-filename_1.docx'
$upload->upload($_FILES['file_upload'], $filename);
use Pop\File\Dir;
$dir = new Dir('my-dir');
foreach ($dir->getFiles() as $file) {
echo $file;
}
use Pop\File\Dir;
$dir = new Dir('my-dir', [
'absolute' => true,
'recursive' => true
]);
foreach ($dir->getFiles() as $file) {
echo $file;
}
use Pop\File\Dir;
$dir = new Dir('my-dir');
$dir->emptyDir(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.