Shellanza Posted May 31, 2016 Share Posted May 31, 2016 Hi there, sorry for the URGENT but the ecommerce is down due this issue and you know... So. Basically I have webservices to update images related to a product. Before the upgrade from php 5.3.3 to Php 5.6 everything was fine. Now if I run the API everything seems ok (I get "success") but no image is uploaded. Let say that: 1) From backoffice the upload work (so folder's permission should be right) 2) The API return me everything well ("success") Now, I got the response from CURL. This is my CURL function: function setProductImages($productId, $request){ /* Here we add an image a created product */ $url = PS_SHOP_PATH."api/images/products/".$productId; $ch = curl_init(); $strExplodedImages = explode("|", $request['image_path']); foreach ($strExplodedImages as $imgPath) { $image_path = PS_SHOP_DOCUMENT_PRODUCT_IMAGE_PATH.$imgPath; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'.$image_path.';type=image/jpg')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); #curl_setopt($ch, CURLOPT_VERBOSE, true); $result = curl_exec($ch); } #curl_getinfo($ch); curl_close($ch); #die(); } And this is the response I get: HTTP REQUEST HEADER GET //api/products/120?schema=synopsis HTTP/1.1 Host: whalesbay.it Authorization: Basic Mk02TEJXSVNOVEVKS0dBUVFHN0hRUlc2R1dQWTRRNU46 Accept: */* HTTP RESPONSE HEADER HTTP/1.1 200 OK Date: Tue, 31 May 2016 16:34:08 GMT Server: Apache Access-Time: 1464712449 X-Powered-By: PrestaShop Webservice PSWS-Version: 1.6.1.5 Execution-Time: 0.053 Content-Sha1: 70f256a4343bf9701b2a4bc8acf386d1fdb1a855 X-Powered-By: PleskLin Connection: close Transfer-Encoding: chunked Content-Type: text/xml;charset=utf-8 RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id><![CDATA[120]]></id> <id_manufacturer xlink:href="http://whalesbay.it/api/manufacturers/1"><![CDATA[1]]></id_manufacturer> <id_supplier xlink:href="http://whalesbay.it/api/suppliers/1"><![CDATA[1]]></id_supplier> <id_category_default xlink:href="http://whalesbay.it/api/categories/2"><![CDATA[2]]></id_category_default> <new></new> <cache_default_attribute><![CDATA[1430]]></cache_default_attribute> <id_default_image notFilterable="true"></id_default_image> <id_default_combination xlink:href="http://whalesbay.it/api/combinations/1430" notFilterable="true"><![CDATA[1430]]></id_default_combination> <id_tax_rules_group><![CDATA[0]]></id_tax_rules_group> <position_in_category notFilterable="true"><![CDATA[0]]></position_in_category> <manufacturer_name notFilterable="true"><![CDATA[Whalesbay]]></manufacturer_name> <quantity notFilterable="true"><![CDATA[0]]></quantity> <type notFilterable="true"><![CDATA[simple]]></type> <id_shop_default><![CDATA[1]]></id_shop_default> <reference><![CDATA[Prova]]></reference> <supplier_reference></supplier_reference> <location></location> <width><![CDATA[0.000000]]></width> <height><![CDATA[0.000000]]></height> <depth><![CDATA[0.000000]]></depth> <weight><![CDATA[0.000000]]></weight> <quantity_discount><![CDATA[0]]></quantity_discount> <ean13></ean13> <upc></upc> <cache_is_pack><![CDATA[0]]></cache_is_pack> <cache_has_attachments><![CDATA[0]]></cache_has_attachments> <is_virtual><![CDATA[0]]></is_virtual> <on_sale><![CDATA[0]]></on_sale> <online_only><![CDATA[0]]></online_only> <ecotax><![CDATA[0.000000]]></ecotax> <minimal_quantity><![CDATA[0]]></minimal_quantity> <price><![CDATA[50.000000]]></price> <wholesale_price><![CDATA[0.000000]]></wholesale_price> <unity></unity> <unit_price_ratio><![CDATA[0.000000]]></unit_price_ratio> <additional_shipping_cost><![CDATA[0.00]]></additional_shipping_cost> <customizable><![CDATA[0]]></customizable> <text_fields><![CDATA[0]]></text_fields> <uploadable_files><![CDATA[0]]></uploadable_files> <active><![CDATA[1]]></active> <redirect_type></redirect_type> <id_product_redirected><![CDATA[0]]></id_product_redirected> <available_for_order><![CDATA[0]]></available_for_order> <available_date><![CDATA[0000-00-00]]></available_date> <condition><![CDATA[new]]></condition> <show_price><![CDATA[0]]></show_price> <indexed><![CDATA[1]]></indexed> <visibility><![CDATA[both]]></visibility> <advanced_stock_management><![CDATA[0]]></advanced_stock_management> <date_add><![CDATA[2016-05-31 18:03:40]]></date_add> <date_upd><![CDATA[2016-05-31 18:11:25]]></date_upd> <pack_stock_type><![CDATA[0]]></pack_stock_type> <meta_description><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[EXPLORER T-SHIRT (60%Cotone 40%Poliestere)]]></language></meta_description> <meta_keywords><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[Pantalone]]></language></meta_keywords> <meta_title><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[EXPLORER T-SHIRT]]></language></meta_title> <link_rewrite><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[non_lo_so_3]]></language></link_rewrite> <name><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[Prova]]></language></name> <description><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[EXPLORER T-SHIRT (60%Cotone 40%Poliestere)]]></language></description> <description_short><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[EXPLORER T-SHIRT]]></language></description_short> <available_now><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[]]></language></available_now> <available_later><language id="2" xlink:href="http://whalesbay.it/api/languages/2"><![CDATA[]]></language></available_later> <associations> <categories nodeType="category" api="categories"> <category xlink:href="http://whalesbay.it/api/categories/2"> <id><![CDATA[2]]></id> </category> <category xlink:href="http://whalesbay.it/api/categories/3"> <id><![CDATA[3]]></id> </category> </categories> <images nodeType="image" api="images"/> <combinations nodeType="combination" api="combinations"> <combination xlink:href="http://whalesbay.it/api/combinations/1430"> <id><![CDATA[1430]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1431"> <id><![CDATA[1431]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1432"> <id><![CDATA[1432]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1433"> <id><![CDATA[1433]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1434"> <id><![CDATA[1434]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1435"> <id><![CDATA[1435]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1436"> <id><![CDATA[1436]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1437"> <id><![CDATA[1437]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1438"> <id><![CDATA[1438]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1439"> <id><![CDATA[1439]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1440"> <id><![CDATA[1440]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1441"> <id><![CDATA[1441]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1442"> <id><![CDATA[1442]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1443"> <id><![CDATA[1443]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1444"> <id><![CDATA[1444]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1445"> <id><![CDATA[1445]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1446"> <id><![CDATA[1446]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1447"> <id><![CDATA[1447]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1448"> <id><![CDATA[1448]]></id> </combination> <combination xlink:href="http://whalesbay.it/api/combinations/1449"> <id><![CDATA[1449]]></id> </combination> </combinations> <product_option_values nodeType="product_option_value" api="product_option_values"> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/1"> <id><![CDATA[1]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/7"> <id><![CDATA[7]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/8"> <id><![CDATA[8]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/3"> <id><![CDATA[3]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/14"> <id><![CDATA[14]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/2"> <id><![CDATA[2]]></id> </product_option_value> <product_option_value xlink:href="http://whalesbay.it/api/product_option_values/9"> <id><![CDATA[9]]></id> </product_option_value> </product_option_values> <product_features nodeType="product_feature" api="product_features"> <product_feature xlink:href="http://whalesbay.it/api/product_features/0"> <id><![CDATA[0]]></id> <id_feature_value xlink:href="http://whalesbay.it/api/product_feature_values/0"><![CDATA[0]]></id_feature_value> </product_feature> </product_features> <tags nodeType="tag" api="tags"> <tag xlink:href="http://whalesbay.it/api/tags/0"> <id><![CDATA[0]]></id> </tag> </tags> <stock_availables nodeType="stock_available" api="stock_availables"> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1498"> <id><![CDATA[1498]]></id> <id_product_attribute><![CDATA[0]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1499"> <id><![CDATA[1499]]></id> <id_product_attribute><![CDATA[1430]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1500"> <id><![CDATA[1500]]></id> <id_product_attribute><![CDATA[1431]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1501"> <id><![CDATA[1501]]></id> <id_product_attribute><![CDATA[1432]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1502"> <id><![CDATA[1502]]></id> <id_product_attribute><![CDATA[1433]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1503"> <id><![CDATA[1503]]></id> <id_product_attribute><![CDATA[1434]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1504"> <id><![CDATA[1504]]></id> <id_product_attribute><![CDATA[1435]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1505"> <id><![CDATA[1505]]></id> <id_product_attribute><![CDATA[1436]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1506"> <id><![CDATA[1506]]></id> <id_product_attribute><![CDATA[1437]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1507"> <id><![CDATA[1507]]></id> <id_product_attribute><![CDATA[1438]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1508"> <id><![CDATA[1508]]></id> <id_product_attribute><![CDATA[1439]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1509"> <id><![CDATA[1509]]></id> <id_product_attribute><![CDATA[1440]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1510"> <id><![CDATA[1510]]></id> <id_product_attribute><![CDATA[1441]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1511"> <id><![CDATA[1511]]></id> <id_product_attribute><![CDATA[1442]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1512"> <id><![CDATA[1512]]></id> <id_product_attribute><![CDATA[1443]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1513"> <id><![CDATA[1513]]></id> <id_product_attribute><![CDATA[1444]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1514"> <id><![CDATA[1514]]></id> <id_product_attribute><![CDATA[1445]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1515"> <id><![CDATA[1515]]></id> <id_product_attribute><![CDATA[1446]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1516"> <id><![CDATA[1516]]></id> <id_product_attribute><![CDATA[1447]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1517"> <id><![CDATA[1517]]></id> <id_product_attribute><![CDATA[1448]]></id_product_attribute> </stock_available> <stock_available xlink:href="http://whalesbay.it/api/stock_availables/1518"> <id><![CDATA[1518]]></id> <id_product_attribute><![CDATA[1449]]></id_product_attribute> </stock_available> </stock_availables> <accessories nodeType="product" api="products"/> <product_bundle nodeType="product" api="products"/> </associations> </product> </prestashop> The image is not getting uploaded. What the hell could it be? Maybe some PHP server side configuration? Thanks in advance. Link to comment Share on other sites More sharing options...
Shellanza Posted June 1, 2016 Author Share Posted June 1, 2016 SOLVED! Php 5.6 give as deprecated @image in Curl Old instruction curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'.$image_path.';type=image/jpg')); New Instruction curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => new CurlFile($image_path)); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now