<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hardy Smith</title>
    <description>The latest articles on DEV Community by Hardy Smith (@hunter_1225).</description>
    <link>https://dev.to/hunter_1225</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1894554%2F005fc79d-8c35-4470-9d07-8be174feda36.png</url>
      <title>DEV Community: Hardy Smith</title>
      <link>https://dev.to/hunter_1225</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hunter_1225"/>
    <language>en</language>
    <item>
      <title>Upload Image into imgbb.com</title>
      <dc:creator>Hardy Smith</dc:creator>
      <pubDate>Wed, 07 Aug 2024 05:49:27 +0000</pubDate>
      <link>https://dev.to/hunter_1225/upload-image-into-imgbbcom-1p58</link>
      <guid>https://dev.to/hunter_1225/upload-image-into-imgbbcom-1p58</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $uploadedImageUrls = [
            $request-&amp;gt;license_verification,
            $request-&amp;gt;driver_photo,
            $request-&amp;gt;car_photo
        ];

        $savedImgUrls = array(); // Initialize array to store the uploaded image URLs

        foreach ($uploadedImageUrls as $base64Image) {
            $ch = curl_init(); // Initialize cURL session for each image upload

            // Set the unique image name for upload
            $uniqueImageName = uniqid() . '_image.png';

            // Set the cURL options
            curl_setopt($ch, CURLOPT_URL, 'https://api.imgbb.com/1/upload');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                'key' =&amp;gt; "cfdb0e89363c14687341dbc25d1e1d43",
                'image' =&amp;gt; $base64Image, // Use the base64-encoded image data
                'name' =&amp;gt; $uniqueImageName // Set the unique image name for upload
            ));

            // Execute the cURL request
            $response = curl_exec($ch);

            // Handle the API response and extract the image URL
            $responseData = json_decode(
                $response,
                true
            );
            if (isset($responseData['data']['url'])) {
                $uploadedImageUrl = $responseData['data']['url'];
                $savedImgUrls[] = $uploadedImageUrl;
            } else {
                // Handle the case where the 'data' key is undefined
                return response()-&amp;gt;json([
                    'error' =&amp;gt; 'Choose correct image.',
                    'statusCode' =&amp;gt; 400
                ], 400);
            }

            curl_close($ch); // Close cURL session after each request
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this code $response has same url every loop. How can solve thi&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>help</category>
    </item>
  </channel>
</rss>
