dimanche 1 juillet 2018

tmp file gets deleted before it can be uploaded. spatie/laravel-medialibrary

I'm trying to update user profile photos using this library.

The process includes uploading the photo as tmp file on my machine/server then uploading it to S3.

However, the tmp file gets cleared before it can be upoaded so I receive this error:

C:\\xampp\\tmp\/php808C.tmp does not exist

This is my code:

public function registerMediaConversions(\Spatie\MediaLibrary\Media $media = null ) {
    $this->addMediaConversion('thumb')->setManipulations( new Manipulations($this->thumb) );
    $this->addMediaConversion('large')->setManipulations(  new Manipulations($this->large) );
}


public function profilePhoto( $photo = null ) {
    if ( Ut::isUrl( $photo ) ) {
        return $this->clearMediaCollection( 'profile' )->addMediaFromUrl( $photo )->toMediaCollection( 'profile' );
    }

    if ( $photo instanceof UploadedFile ) {
        return $this->clearMediaCollection( 'profile' )->addMedia( $photo )->toMediaCollection( 'profile' );
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KCPNsA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire