-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbase64.php
28 lines (21 loc) · 6.66 KB
/
base64.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require __DIR__ . '/../src/Uploader.php';
use \iamdual\Uploader;
if (isset($_POST["data"])) {
$upload = new Uploader(Uploader::from_base64($_POST["data"]));
$upload->allowed_extensions(array("png", "jpg", "jpeg", "gif"));
$upload->max_size(5); // in MB
$upload->path("upload/files");
$upload->name("unicorn");
// While uploading file from base64 encoded file, you need to enable the "copy file" feature
// by appending "true" to the upload() method. Otherwise file can not be uploaded!
if (! $upload->upload(true)) {
echo "Upload error: " . $upload->get_error();
} else {
echo "Upload successful: " . $upload->get_name();
}
}
?>
<form action="" method="post">
Enter Base64 encoded file: <input type="text" name="data" value="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAA7EAAAOxAGVKw4bAAARIklEQVR42u1aaXRVVZb+zp3efUPelJfkvcwkIQTIYMIghKm6ROnVUCyXa2mDbVkqvRSLBtvZRVWJdNlWwaKVUIi2VViljRpw2UU1oA0yGYltUZAygiaEMIRMEDK8Me/d8fSPR0JGkpCgsLr3n3fvefecc/e3v73PPvtc4P+4kOvptHbt2ixPaup/UlWtrzt3bskrr7wSuFUB4K6nk9VqXWicPTuPEcW8tL17P3n++ecXrFu3LjSSMUpLSx9nWbb53nvv3XnLMeDJJ59MmFxcXB1zzz320L59kC9cOFBdVbVw48aN0nD6b9++/Q5K6X4AGsMws++7774vbykAAGDLli2rLLNnl6iXLoHzeBD+4ovd337zzT0lJSXKUH137tz5hqIoywVBQCQSOXn8+PGi9evXK7eMCwDAZ5999voPRfER1uEoMGSNB0u4RZMofX/VP65Ysul3r2v/lrrCmi54cuN4ezoH1gpAC+vSxVAO97WkKIvdbjfS09NRXl6eW1hYuBLAq+tTfmqK5azJy879uuamZwAArF+/fpbNbi+LX/IQI3oVSN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