Uploaded image for project: 'PrestaShop 1.7'
  1. PrestaShop 1.7
  2. BOOM-4799

probleme ajout image produit CURL - Erreur 500 internal Server

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.2.4
    • Fix Version/s: None
    • Component/s: None
    • How to reproduce the issue ?:
      N/A
    • Tests & Expected Results:
      N/A
    • Documentation Change:
      N/A

      Description

      Bonjour,

       

      ajout image produit via code html : FONCTIONNE BIEN.

      <form enctype="multipart/form-data" method="POST" action="http://xxxxxxxxxxxxx@servweb.gpart.fr/prestashop_1.7.2.4/api/images/products/23/">
      <fieldset>
      <legend>Add image for products No 1</legend>
      <input type="file" name="image">
      <input type="submit" value="Execute">
      </fieldset>
      </form>

       

      ajout image produit via curl : NE FONCTIONNE PAS.  500 INTERNAL SERVER ERROR

      $url = 'https://servweb.gpart.fr/prestashop_1.7.2.4/api/images/products/12';
      $image_path = './tmpimages/image01.jpeg';
      $key = 'xxxxxxxxxxxxx';

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:multipart/form-data','Expect:'));
      curl_setopt($ch,CURLOPT_FAILONERROR,true);

      curl_setopt($ch, CURLOPT_URL, $url);
      //curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_PUT, true);
      curl_setopt($ch, CURLOPT_USERPWD, $key.':');
      curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@'.$image_path.';type=image/jpeg'));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      if(curl_exec($ch) === false)
      {
          echo 'Erreur Curl : ' . curl_error($ch);
      }
      else
      {
      echo 'L\'opération s\'est terminée sans aucune erreur';
      }

      curl_close($ch);

       

      MERCI D'AVANCE POUR VOTRE AIDE.

      Cordialement,

       

      Guy.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              guy Guy Wolff
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: