upload image by api laravel controller
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
upload image by api laravel controller
I am working on adding media item to table mshop_media.
I created my controller on this path.
And added this code
But i get an error when i used this class :
Error Message:
PHP Version 8.2.12
Laravel version: 10
Aimeos version: 2023.10
Environment: windows (XAMPP cross-platform web server).
I created my controller on this path.
Code: Select all
app\Http\Controllers\AddProductController.php
Code: Select all
$context = app('aimeos.context')->get();
$managerMedia = \Aimeos\MShop::create( $context, 'media' );
$cntlMedia = \Aimeos\Controller\Common\Media\Factory::create( $context );
$mediaItem = $managerMedia->get(175);
$cntlMedia->add($mediaItem,$request->file('img'));
Code: Select all
Aimeos\Controller\Common\Media\Factory
Code: Select all
TypeError: Aimeos\Controller\Common\Media\Standard::add(): Argument #2 ($file) must be of type Psr\Http\Message\UploadedFileInterface, Illuminate\Http\UploadedFile given, called in C:\xampp\htdocs\myshop\app\Http\Controllers\AddProductController.php on line 29 in file C:\xampp\htdocs\myshop\vendor\aimeos\aimeos-core\src\Controller\Common\Media\Standard.php on line 46
Laravel version: 10
Aimeos version: 2023.10
Environment: windows (XAMPP cross-platform web server).
Re: upload image by api laravel controller
Expect a PSR-7 request in your action instead of a Laravel request. Then, you also get a PSR-7 file upload object which you can use:
https://laravel.com/docs/11.x/requests#psr7-requests
https://laravel.com/docs/11.x/requests#psr7-requests
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star