How to save DATA URL like save $_FILES in php?
my code is:
$dataurl = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAB...."
$image_content = base64_decode(str_replace("#^data:image/\w+;base64,#i","", $dataurl)); // remove "data:image/png;base64,"
$tempfile = tmpfile(); // create temporary file
$filesize = fwrite($tempfile, $image_content); // fill data to temporary file
$metaDatas = stream_get_meta_data($tempfile);
$tmpFilename = $metaDatas['uri'];
$file = array(
'name' => 'MyFile.jpg',
'type' => 'image/jpeg',
'tmp_name' => $tmpFilename,
'error' => 0,
'size' => $filesize,
);
move_uploaded_file($file['tmp_name'], $location);
The problem maybe in move_uploaded_file($file['tmp_name'], $location);