1 | <?php
|
---|
2 |
|
---|
3 | //
|
---|
4 | // In Open Flash Chart -> save_image debug mode, you
|
---|
5 | // will see the 'echo' text in a new window.
|
---|
6 | //
|
---|
7 |
|
---|
8 | /*
|
---|
9 |
|
---|
10 | print_r( $_GET );
|
---|
11 | print_r( $_POST );
|
---|
12 | print_r( $_FILES );
|
---|
13 |
|
---|
14 | print_r( $GLOBALS );
|
---|
15 | print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
|
---|
16 |
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | // default path for the image to be stored //
|
---|
21 | $default_path = '../tmp-upload-images/';
|
---|
22 |
|
---|
23 | if (!file_exists($default_path)) mkdir($default_path, 0777, true);
|
---|
24 |
|
---|
25 | // full path to the saved image including filename //
|
---|
26 | $destination = $default_path . basename( $_GET[ 'name' ] );
|
---|
27 |
|
---|
28 | echo 'Saving your image to: '. $destination;
|
---|
29 | // print_r( $_POST );
|
---|
30 | // print_r( $_SERVER );
|
---|
31 | // echo $HTTP_RAW_POST_DATA;
|
---|
32 |
|
---|
33 | //
|
---|
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
|
---|
37 | //
|
---|
38 |
|
---|
39 | $jfh = fopen($destination, 'w') or die("can't open file");
|
---|
40 | fwrite($jfh, $HTTP_RAW_POST_DATA);
|
---|
41 | fclose($jfh);
|
---|
42 |
|
---|
43 | //
|
---|
44 | // LOOK:
|
---|
45 | //
|
---|
46 | exit();
|
---|
47 |
|
---|
48 |
|
---|
49 | //
|
---|
50 | // PHP5:
|
---|
51 | //
|
---|
52 |
|
---|
53 |
|
---|
54 | // default path for the image to be stored //
|
---|
55 | $default_path = 'tmp-upload-images/';
|
---|
56 |
|
---|
57 | if (!file_exists($default_path)) mkdir($default_path, 0777, true);
|
---|
58 |
|
---|
59 | // full path to the saved image including filename //
|
---|
60 | $destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
|
---|
61 |
|
---|
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";
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | ?>
|
---|