images in repeatable field saving as base64, would like to save in storage #683
-
I have a repeatable field, and it has images. It all works fine, except the images are being saved as base64 to the database, and I'd like to direct them to a storage location. This works fine outside the repeatable, but if I try to put 'withFiles' => true into a repeatable, I then get an error on save: Is there a parameter I am missing to make the image in a repeatable upload to storage, or do I need to use a callback? Thanks!!! ======================================================== This subfield works and uploads base64: But this subfield does not and throws the error: [ |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @semiplay I tried to recreate and it worked for me with the following code: Model protected $casts = [
'json' => 'json',
]; Controller CRUD::field([
'name' => 'json',
'label' => 'IMAGES WITH TEXT',
'type' => 'repeatable',
'subfields' => [ // also works as: "fields"
[
'name' => 'text',
'type' => 'text',
'label' => 'TEXT',
'wrapper' => ['class' => 'form-group col-md-4'],
],
[
'name' => 'image',
'type' => 'image',
'label' => 'IMAGE',
'crop' => true,
'aspect_ratio' => 1,
'withFiles' => [
'disk' => 'public', // the disk where file will be stored
'path' => 'uploads', // the path inside the disk where file will be stored
],
'wrapper' => ['class' => 'form-group col-md-4'],
],
],
'reorder' => true, // show up&down arrows next to each row
]); Schema::create('testimonials', function (Blueprint $table) {
$table->id();
$table->json('json');
$table->timestamps();
}); Result"[{\"text\":\"SAsa\",\"image\":\"uploads\\/kQNr94ssiuztwCVlOnSmVNFP388yXcViRUEZowsI.png\"}]" Caution
|
Beta Was this translation helpful? Give feedback.
-
@karandatwani92 it works! Thank you so much! |
Beta Was this translation helpful? Give feedback.
Hey @semiplay I tried to recreate and it worked for me with the following code:
Model
Controller