0261f9aeae40a4d8de23d4201c18c42097752a87
[openemr.git] / library / openflashchart / php-ofc-library / ofc_upload_image.php
blob0261f9aeae40a4d8de23d4201c18c42097752a87
1 <?php
3 //
4 // In Open Flash Chart -> save_image debug mode, you
5 // will see the 'echo' text in a new window.
6 //
8 /*
10 print_r( $_GET );
11 print_r( $_POST );
12 print_r( $_FILES );
14 print_r( $GLOBALS );
15 print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
20 // default path for the image to be stored //
21 $default_path = '../tmp-upload-images/';
23 if (!file_exists($default_path)) mkdir($default_path, 0777, true);
25 // full path to the saved image including filename //
26 $destination = $default_path . basename( $_GET[ 'name' ] );
28 echo 'Saving your image to: '. $destination;
29 // print_r( $_POST );
30 // print_r( $_SERVER );
31 // echo $HTTP_RAW_POST_DATA;
34 // POST data is usually string data, but we are passing a RAW .png
35 // so PHP is a bit confused and $_POST is empty. But it has saved
36 // the raw bits into $HTTP_RAW_POST_DATA
39 $jfh = fopen($destination, 'w') or die("can't open file");
40 fwrite($jfh, $HTTP_RAW_POST_DATA);
41 fclose($jfh);
44 // LOOK:
46 exit();
50 // PHP5:
54 // default path for the image to be stored //
55 $default_path = 'tmp-upload-images/';
57 if (!file_exists($default_path)) mkdir($default_path, 0777, true);
59 // full path to the saved image including filename //
60 $destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
62 // move the image into the specified directory //
63 if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
64 echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
65 } else {
66 echo "FILE UPLOAD FAILED";