Magento – Upload Image Magento API

image-uploadmagento-1.9soap

I'm creating a SOAP v2 api in Magento, and one of the methods is to upload an image to the Magento media folder.
So my question is: how can I send an image to magento without using a form? and how can I upload it to the media folder.

Best Answer

The easiest way is place images to media/import folder before and then use

$product->addImageToMediaGallery($filePath, array ('image','small_image','thumbnail'), false, false);

function.

Check this comment for the full description of this function addImageToMediaGallery copy the image file to media folder

If you can't upload images, you can use two ways:

  1. Send images to API as strings and on your side use file_put_contents to save it

  2. Send images to API as links and on your side use file_get_contents/file_put_contents to get/save them

Related Topic