1. Go to this page and download the library: Download haldayne/customs 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/ */
haldayne / customs example snippets
use Haldayne\Customs;
$uploads = new UploadIterator();
foreach ($uploads as $file) {
$stored_path = $file->moveTo('/path/to/folder/');
echo "The file was permanently stored at $stored_path.";
}
use Haldayne\Customs;
try {
$uploads = new UploadIterator();
} catch (ServerProblemException $ex) {
// uh oh, your server has a problem: no temp dir for storing files,
// couldn't write file, extension prevents upload, etc. You need to
// handle this, because the user didn't do anything wrong.
throw $ex;
} catch (SecurityConcernException $ex) {
// uh oh, the user provided something that looks like an attempt to
// break in. You might want to just rethrow this exception, or maybe
// you want to honeypot the user.
error_log("Break in attempt");
echo "Your file received";
return;
}
foreach ($uploads as $file) {
if ($file instanceof UploadError) {
echo 'Sorry, your upload was not stored.';
// you can discover the original HTML name for the file input
echo $file->getHtmlName();
// you can emit a generic message...
echo $file->getErrorMessage();
// ... or you can get specific.
if ($file->isTooBig($maximum)) {
echo "The file was too big. Maximum is $maximum bytes.";
} else if ($file->isPartial($received)) {
echo "The file upload wasn't complete. Only $received bytes received.";
} else if ($file->notUploaded()) {
echo "No file uploaded.";
}
} else {
// $file is an instance of UploadFile: now you can check for domain-
// specific errors
if ($file->getServerFile()->getFileSize() < 100) {
echo "Minimum file size is 100 bytes.";
} else if (! $file->getMimeAnalyzer()->isAnImage()) {
echo "You must upload an image file.";
} else {
$file->moveTo('/path/to/images');
}
}
}
<input type='file' name='file[A]' />
<input type='file' name='file[B]' />
/* // $_FILES = array (
"file" => array ( // notice only one outer element
"name" => array ( // with array keys!
"A" => "cat.png",
"B" => "dog.png"
),
"type" => array (
"A" => "image/png",
"B" => "image/png"
),
"tmp_name" => array (
"A" => "/tmp/phpZuLGPe",
"B" => "/tmp/phpUee89j"
),
"error" => array (
"A" => 0,
"B" => 0
),
"size" => array (
"A" => 35669,
"B" => 43225
)
)
)
*/
use Haldayne\UploadIterator;
foreach (new UploadIterator as $file) {
if ($file instanceof UploadFile) {
$stored_path = $file->move('/path/to/folder/');
// you choose "where" the file goes, not what it will be named
// $stored_path === /path/to/folder/69c779f0746503ba7e42f87ce1e91152.png
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.