Get "Can't get target upload source info" when uploading image use base64 by api

supersky07

New Member
▶🚶‍Reproduction steps
  1. get my demo image base64
  2. encode it
    encoded base64:
    ZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFFWUFBQUJHQ0FZQUFBRUdLZElTQUFBQUFYTlNSMElBcnM0YzZRQUFFT05KUkVGVWVBSHRQQXQwbE1XNU0vTS9OMDhnSkFTMGlMZ2JvZ3UwQ2tMbEZSNHFCZHNEY3IzYWk2K2psbDZ0UlcvTmFkWEF0ZkVvWUxtdG50b2k0TDIxTDZvZXJTaDZVYlNLSVFFa0VnUkR3aXRKZ2ZMSUV4THkyUC85ei8xbWNjTy9tOTNON3JMWmVzNWx6dG44OC9qbW0yKytmK1o3emZ4QktDU3BPOXczaDFRaEVsclIvci9TaCszLzhhMUJvZldKbDVWeU53MzB4c3EycTJaM2JKRS9HYjZxRnJQS3hpZTkvc1pCOHpUVXNVWDZuR0EwbnJpS0dyYjZiQ1VzRGNOWDFrNGVQRS92OXZjT29IVU93ZXBjTStxRDJnTndxRzI1ZDFkdjRhdE1IeFpRaXEvV3QzdGFRd0dEeXZvTzk1cWdpdEFDY1B1L0E3TUxiWXU5VEQvMzlESXZ0QmQvOHBIeGM3SUcwNDhSVW5zWmlTbGFuUDljN1d0czZNSHpOSVZjZHFmeWNkYlQrOFB5SXgybEQ1Vm4xS2YxTnJMaFZQWENpQkVaeVdocFhlYTFRbWtLWWliREp2RWtxSTUxNkIwdXREY3IwOTBlZXZJdjhudzVqUzRldWtDN0MwK3Vpd29mRGtkdlhkZlB4OUdXWldNdlRLaTNKVGdUZGdSYVBZWWlCek9DdThBMEpoM3AwODgvVnpZRmVQMHY5WFpRYlQ5dzA5c0NjdjZhTndxTFZXZ0xKTFBTODJMZ2hST2xvbUJWMDErbDM4T0dmS2lscFA4cEJKQTBsWGl0MW5mRXBWMmJaV1I5NXFGOVNHU0FiQlE4cVE3REtya3QwSkU5YllJcmg4e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Vh6RXQ2NGZuMmpYUWh0aC81VGpTVUdDbkFBaDF0Zmt1RStDYThuSk93cStBcC90Z0pQaGsxNmVNTWVEQ3JrWGdlRUY0OHU1di9IdlBPS3VMZkJmaXdqYTczaHFhbUhNSFBtK24yWUxtWkM1c3VSKytJNWlpOThDRmNCdXZEWVVkcUhKZnFnWnFKTUNybEhudWcyOW9YMkZCTC9CWFBoT3l5RjBuZml0aTF4QzhHRTVjSnJEZFF5eTBvK3NzZnUzeUgvbStRUlh5R3NnZ04yd3B3ekxzdWE2WkRaOE9JSGxCcUZQS0dEWXlmUU54NmpEUDB4eVBmaVpJV0dDeElGV0JLN2tZZFVJZWcwOEgveUVFRmpKUVp1bjJPUWl6bHNBVkxmOTE0Q0RLQjdpUWNzYUV6b2QrVmpoS004MXhFRlM2d29aSU55ZWlCbDRVcXZIRWc0MmhzS2tzL3grNjFnYUlLM0F0MGdBQUFBQkpSVTVFcmtKZ2dnPT0=
  3. post it to the api with key and format
😢Unexpected result

Response status is 400, and the error text is "Can't get target upload source info"

📃Error log message

chevereto_1 | [Sun Mar 01 14:47:29.960338 2020] [php7:notice] [pid 17] [client 172.19.0.1:51356] Can't get target upload source info
chevereto_1 | 172.19.0.1 - - [01/Mar/2020:14:47:29 +0000] "POST /api/1/upload HTTP/1.0" 400 607 "-" "-"
 

supersky07

New Member
Your base64 string is corrupted. You can check it here: https://codebeautify.org/base64-to-image-converter

Thank you for reply. The base64 code above is encoded.

I have read the source code, the code will decode it. And then write it to the file. So I give the encoded one.

Now I decode the encoded base64 code by `base64_decode` function, and get the code below.

base64 code:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAAEGKdISAAAAAXNSR0IArs4c6QAAEONJREFUeAHtPAt0lMW5M/M/N08gJAS0iLgbogu0CkLlFR4qBdsDcr3ai6+jll6tRW/NadXAtfEoYLmtntoi4L21L6oerSh6UbSKIQEkEgRDwitJgfLIExLy2P/9z/1mccO/m93N7rLZes5lztn88/jmm2++f+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ii98CFcBuvDYUdqHJfqgZqJMCrlHnug29oX2FBL/BXPhOyyF0nfiti1xC8GE5cJrDdQyy0o+ssfu3yH/m+QRXyGsggN2wpwzLsua6ZDZ8OIHlBqFPKGDYyfQNx6jDP0xyPfiZIWGCxIFWBK7kYdUIeg08H/yEEFjJQZun2OQizlsAVLf914CDKB7iQcsaEzod+VjhKM81xEFS6woZINyeiBl4UqvHEg42hsKks/x+61gaIK3At0gAAAABJRU5ErkJggg==
 

supersky07

New Member
Your base64 string is corrupted. You can check it here: https://codebeautify.org/base64-to-image-converter
here is the code in 'routes.api.php'

api code:
// From _GET source should be urlencoded base64
if(!G\timing_safe_compare(base64_encode(base64_decode($source)), $source)){
    throw new Exception('Invalid base64 string.', 120);
}

// Set the API temp file
$api_temp_file = @tempnam(sys_get_temp_dir(), 'chvtemp');

if(!$api_temp_file or !@is_writable($api_temp_file)) {
throw new UploadException("Can't get a tempnam.", 200);
}

$fh = fopen($api_temp_file, 'w');
stream_filter_append($fh, 'convert.base64-decode', STREAM_FILTER_WRITE);
if(!@fwrite($fh, $source)) {
    throw new Exception('Invalid base64 string.', 130);
} else {
    // Since all the validations works with $_FILES, we're going to emulate it.
    $source = array(
        'name'        => G\random_string(12).'.jpg',
        'type'        => 'image/jpeg',
        'tmp_name'    => $api_temp_file,
        'error'        => 'UPLOAD_ERR_OK',
        'size'        => '1'
    );
}
If I pass the original base64 code, it will throw the exception ` throw new Exception('Invalid base64 string.', 120);`
 

supersky07

New Member
Thank you for reply. The base64 code above is encoded.

I have read the source code, the code will decode it. And then write it to the file. So I give the encoded one.

Now I decode the encoded base64 code by `base64_decode` function, and get the code below.

base64 code:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAAEGKdISAAAAAXNSR0IArs4c6QAAEONJREFUeAHtPAt0lMW5M/M/N08gJAS0iLgbogu0CkLlFR4qBdsDcr3ai6+jll6tRW/NadXAtfEoYLmtntoi4L21L6oerSh6UbSKIQEkEgRDwitJgf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