<?php
//just a random name for the image file
$random = rand(100, 1000);
//$_POST[data][1] has the base64 encrypted binary codes.
//convert the binary to image using file_put_contents
$savefile = @file_put_contents("output/$random.jpg", base64_decode(explode(",", $_POST['data'])[1]));
//if the file saved properly, print the file name
if($savefile){
echo $random;
}
?>
You don't have permission to access /test/div2img/output/<br /><b>Parse error</b>: syntax error, unexpected '[' in <b>C:/AppServ/www/test/div2img/save_jpg.php</b> on line <b>8</b><br />.jpg on this server.