title: Base64-Converting string to image not working on all images PHP
body: <p>Good day.I have pretty unusual issue.Whenever i decode any jpeg extensions images from base64,the image will not properly be converted,mainly the image will not be shown at all,but the size,extension all is correct,but when i do download image from server,the image viewer not recognizing image.When i do upload the .png exntensions images,they work great as they should and its really weird to me as i HAVE TO send image with base64,and no other way i want or can.So here is the php code of how do i decode baes64 string image.</p>
  
  <pre><code>function getImageFromString($imagestrng,$imagename,$userid,$uniqueid,$db){
      $imagenamerandom = rand(1, 1000000);
      $ext = pathinfo($imagename, PATHINFO_EXTENSION);
      $imagestrng = str_replace('data:image/'.$ext.';base64,', $imagestrng);
      $imagestrng = str_replace(' ', '+', $imagestrng);
      $data = base64_decode($imagestrng);
      file_put_contents('RequestedImages/'.$imagenamerandom.'.'.$ext, $data);
      $instertresult = $db-&gt;insertImageName($userid, $uniqueid, $imagenamerandom.'.'.$ext);
  }
  </code></pre>
  
  <p>I get this from a tutorial and i think something wrong in str_replace,but still if i do remove them both,same happens!Please someone help me and say what I'm doing wrong?</p>