create('Magento\Framework\Filesystem'); /** @var $tmpDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */ $tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::SYS_TMP); $tmpDirectory->create($tmpDirectory->getAbsolutePath()); $targetTmpFilePath = $tmpDirectory->getAbsolutePath('magento_small_image.jpg'); copy(__DIR__ . '/magento_small_image.jpg', $targetTmpFilePath); // Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir $targetTmpFilePath = $tmpDirectory->getAbsolutePath('magento_empty.jpg'); copy(__DIR__ . '/magento_empty.jpg', $targetTmpFilePath);