- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017
01:46 AM
09-06-2017
01:46 AM
magento 2 doesn't copying product picture in tmp folder
I creating a product pro grammatically in magento2. The issue is that i can't set addImageToMediaGallery. I always receive error:
The file "/home/xxx/pub/media/tmp/catalog/product/t/e/test.jpg" doesn't exist or not a file
My picture locating in /pub/media/testimg/test.jpg media folder and has 777 permissions and files has same perms. Here is a code:
$dir = $objectManager->get('Magento\Framework\App\Filesystem\DirectoryList');
$_product->addImageToMediaGallery($dir->getPath('media') . '/testimg/test.jpg', null, false, false );
so it looks like the system found the image but can't copy in tmp folder ? please help.
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017
09:15 AM
11-21-2017
09:15 AM
Re: magento 2 doesn't copying product picture in tmp folder
This is because your path is wrong. Try to set it like this:
$product->addImageToMediaGallery('testimg' . DIRECTORY_SEPARATOR . 'test.jpg', ['image', 'small_image', 'thumbnail'], false, false);
You don't need to redeclare the path /pub/media/ because magento 2 already declare it when you add image to gallery.
IT Manager/Full stack developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018
08:28 AM
03-01-2018
08:28 AM
Re: magento 2 doesn't copying product picture in tmp folder
Hey there I was wondering in which file this path is located, i'm having the same issue as OP