Open marcalj opened 10 years ago
Why this jsFiddle is working with not same origin images? http://jsfiddle.net/xKJB8/3/
It isn't.
"Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': tainted canvases may not be exported."
It works without errors at the first time, after opening the console and refresh full page doesn't work... strange.
If the image isn't in cache, it won't be drawn and as such the toDataURL
just returns a blank canvas in base64. The image should be drawn only after it has been loaded
I've solved the issue using file_get_contents
. This is the important change (quick&dirty code)
$image = file_get_contents($_GET['url']);
if (false === $image) {
$fp = false;
} else {
fwrite($sf, $image);
$finfo = new finfo(FILEINFO_MIME);
$mime = $finfo->buffer($image) . PHP_EOL;
$mime = preg_split('/;+/', $mime, -1, PREG_SPLIT_NO_EMPTY);
if (is_array($mime)) {
$mime = trim($mime[0]);
}
$allowMimes = Array(
'image/jpeg', 'image/jpg', 'image/png', 'image/gif',
'text/html', 'application/xhtml', 'application/xhtml+xml'
);
if (!in_array($mime, $allowMimes)) {
$err = $mime . ' mime is invalid';
$mime = false;
}
$fp = true;
}
fclose($sf);
Sorry, wrong repo!!!!! :dancer: :S
Example, show Facebook profile images:
https://graph.facebook.com/1415773021975267/picture becomes: https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash1/276836_1415773021975267_370639944_q.jpg
I'm looking at this, but hopefully I will use a hack in my code... Anyone had the same issue?