The tricky part at least for me is to keep everything client-side until the form is sent, otherwise I'd have to save and restore every single input with every new upload
You mean you are refershing the page every time? Use XMLHttp!
Uploads are stored in your server /tmp usually, if the POST didn't go through the uploads will not be moved to your file storage folder. `
As for file upload input vs base64, there's a big difference.
file input will be an instance of Symphony's UploadedFile with all it's methods to check the attributes while base64 is a string without any such options.
At the same time I need to server-side check the attributes of the image the user is trying to upload are valid/allowed.
Use Laravel's validation on file uploads such as mime type.
I have editable image uploads where the edited version will be a base64.
A way to check could be to create an image file from that string and open it in a php image class to get the attributes. Cumbersome maybe ;)
Javascript can do it too assuming your users won't tamper with it. And the editable feature (cropperjs in my case) won't work without a valid image anyway.
public function handle(Filesystem $filesystem)
{
try
{
if ($this->file || $this->cropped)
{
$file = $this->cropped ? base64_decode(str_replace('data:image/png;base64,', '', $this->cropped)) : null;
if (!$file && $this->file instanceof UploadedFile)
$file = $this->file->get();
if (!$file)
return false;
$fileName = strtolower(str_replace(' ', '-', $this->location));
$filesystem->put(
config('catalog.disks.archive.folder') . $fileName, $file);
return $fileName;
}
} catch (\Exception $e)
{
//
}
}