Search code examples
phpvariablesgetmismatch

php GET variable mismatch


I have an android app that uses a URL Connection. The latter part of the URL string is;

./upload_data.php?id=SC1495&image=%3FPNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%02X%00%00%01%15%08%02%00%00%00%3F*%0C%3F%00%00%00%03sBIT%05%06%053%0B%3F%3F%00%00%01%3FIDATx%3F%3F%3F1%01%00%00%00%3F%3FOm%0D%0F%3F%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%3F7%3F%26%00%01%40%3F%27%13%00%00%00%00IEND%3FB%60%3F&imagename=bob&imagetime=20140806+121507

When I put this into the browser and use $_GET['image'], it returns the following; ?PNG IHDRX?*?sBIT3???IDATx???1??Om ??7?&@?'IEND?B?`

I am not decoding anything, I just want to get the string with all the %00 etc.

Can someone enlighten me as to why this would be happening?


Solution

  • $_GET['image'] is returning the correct string. The characters in the url are mainly %00 which is equal to NULL in URL encoding. If you want to keep the characters you can use rawurlencode()

    $img = $_GET['image'];
    
    echo rawurlencode($img);
    

    Or just

    echo urlencode($_GET['image'])
    

    This will convert the characters you've got back to their url encoded form