summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/class.SurveyHeatMapSaveImage.php
blob: 95568806b60b0895c7653a77a69480c5bc5266fc (plain) (blame)
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
/** 
 *  Januar 2017
 * 
 * Shrani heatmap porocilo v obliki slike
 * 
 * @author Patrik Pucer
 */
class SurveyHeatMapImageSave
{	
		
    function __construct() {
    }

    function ajax() {
		
		global $site_url;
		global $site_path;
		
        if(isset($_POST['sprid'])) {
			$sprid = $_POST['sprid'];
			$heatmapId = 'heatmap'.$sprid;
			$img = $_POST['image'];
			
			define('UPLOAD_DIR', $site_path.'main/survey/uploads/');
 			
			$img = str_replace('data:image/png;base64,', '', $img);
			$img = str_replace(' ', '+', $img);
			$data = base64_decode($img);
			$file = UPLOAD_DIR . $heatmapId . '.png';
			$success = file_put_contents($file, $data);
			print $success ? $file : 'Unable to save the file.';
        }
		//exit();
    }
}