Frontend UploadField

Silverstripe Version:
4.2.1

Question:

I recently upgraded my SS3 project to SS4. Most issues resolved, except for finding a suitable replacement for Uncle Cheese Dropzone module (which was perfect, but hasn’t been updated to SS4). Before I make the update live, I really need a frontend UploadField for uploading both images and files. I’ve spent many frustrating hours searching and have tried another module (hudhaifas/silverstripe-frontend-fields) without success. It doesn’t need to be fancy, it just needs to be able to work with either a has_one or many_many relationship.

Any tips on how to set up FileField (or UploadField) on the frontend would be much appreciated.

Did you find a solution to this? I too am struggling to get a basic file uploaded via a frontend form and stored to a has_one File.

Not a standalone module but have a look at the Filepond part of lekoala/silverstripe-base

If you take the parts that you need it’s a pretty elegant solution

2 Likes

Thanks @kafta, I’ll take a look at that.

I’ve also worked out a basic way of saving from a frontend FileField:

$video = $data['Video'];
$content = file_get_contents($video['tmp_name']);
$file = File::create();
$file->setFromString($content, $video['name']);
$file->write();
1 Like