42868d70
andryeyev
Создал GIT
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
// Get the data
$imageData=$GLOBALS['HTTP_RAW_POST_DATA'];
// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
$filteredData=substr($imageData, strpos($imageData, ",")+1);
// Need to decode before saving since the data we received is already base64 encoded
$unencodedData=base64_decode($filteredData);
//echo "unencodedData".$unencodedData;
// Save file. This example uses a hard coded filename for testing,
// but a real application can specify filename in POST variable
// Ñîçäàåì ïàïêó
$root=$_SERVER['DOCUMENT_ROOT']."/";
if (!is_dir($root."xml/".date('Y'))) {
mkdir($root."xml/".date('Y'), 0777, true);
chmod($root."xml/".date('Y'), 0777);
}
if (!is_dir($root."xml/".date('Y')."/".date('m'))) {
mkdir($root."xml/".date('Y')."/".date('m'), 0777, true);
chmod($root."xml/".date('Y')."/".date('m'), 0777);
}
$fp = fopen($root.'xml/'.date('Y').'/'.date('m').'/grafic_report_'.date('Y-m').'-'.(date('d')-1).'.png', 'w' );
fwrite( $fp, $unencodedData);
fclose( $fp );
}
?>
|