2

Working on a project in Backpack for Laravel that involves uploading images, videos, etc. Starting with a simple image upload, I have a mutator in my model as follows:

public function setThumbnailAttribute($value)
{
    $attribute_name = "Thumbnail_URL";
    $disk = "s3";
    $destination_path = "images";

    $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
}

But it doesn't seem to fire, and whenever the file is 'uploaded' it shows a 'C:\Windows\Temp\php6803.tmp' as the location.

My field:

$this->crud->addField([
        'name' => 'Thumbnail',
        'label' => 'Thumbnail',
        'type' => 'image',
        'upload' => true,
        'disk' => 's3' 
    ]);

And my 's3' disk in filesystems.php:

's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
    ],

I've double checked that the Thumbnail_URL is fillable. I'm really not sure what I'm missing.

Johanna H
  • 49
  • 2
  • 4

1 Answers1

0
public function setThumbnailAttribute($value)
{
$attribute_name = "Thumbnail_URL";
$disk = "s3";
$destination_path = "images";

**MISSING** $this->attributes[$attribute_name] = '....' (image path/filename)

$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);

}

  • Thanks for the help! This didn't change anything that I can see though, still stores it in Ctemp and there's nothing in the S3. – Johanna H Jan 16 '18 at 17:24