Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>They are few possible reasons you might be having such </p> <p>A. Wrong content type .. you have <code>Content-type: ".$file['UploadFile']['file_extension']</code> .. that is worng` in your code</p> <p>Eg. Files extention formation is somthing like ".jpg" while the content type is <code>image/jpeg</code></p> <p>B. Your file might not be properly saved which must have lead to the corruption on such image</p> <p>C. File must have been truncated during upload </p> <p>D. <code>$content = addslashes(file_get_contents($source));</code> .. Don't ever <code>addslashes</code> to images .. it would messthing up or get ready to <code>stripslashes</code> when you are loading the image</p> <p>To know if your image is valid before you download you can run this code </p> <pre><code>$image = ImageCreateFromString($file['UploadFile']['file_content']); if(!$image) Something is Wrong </code></pre> <p>You can also use <code>getimagesize</code> to add additional validation </p> <p><strong>Edit 1</strong></p> <p><strong>Prove of Concept</strong> </p> <pre><code>$image = ImageCreateFromString ( $file ['UploadFile'] ['file_content'] ); if ($image) { /** * Check If Height and Width is grater than 1 */ if (ImageSX ( $image ) &gt; 1 &amp;&amp; ImageSY ( $image ) &gt; 1) { $extention = strtolower ( $file ['UploadFile'] ['file_extension'] ); switch ($extention) { case "png" : header ( 'Content-Type: image/png' ); // This is just example imagepng ( $image ); break; case "gif" : header ( 'Content-Type: image/gif' ); // This is just example imagegif ( $image ); break; case "jpg" : case "jpeg" : header ( 'Content-Type: image/jpg' ); // This is just example imagejpeg ( $image ); break; default : die ( "Unsupported Image" ); break; } } else { die ( "Fake Image" ); } } else { die ( "Invalid Image -- Contains Errors" ); }} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload