acknowledgments update
[openemr.git] / interface / patient_file / upload_dialog.php
blob97bc9773bbdbdd04c162153c56e873d03711114b
1 <?php
2 // Copyright (C) 2009-2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
11 $patientid = $_REQUEST["patientid"];
12 $what = $_REQUEST["file"];
14 $patientdir = $GLOBALS['OE_SITE_DIR'] . "/documents/$patientid";
15 $imagedir = "$patientdir/demographics";
17 <html>
18 <head>
19 <title>Upload Image</title>
20 <link rel="stylesheet" href="<?php echo xl($css_header,'e');?>" type="text/css">
21 </head>
22 <body>
24 <?php
25 $errmsg = '';
27 if ($_POST["form_submit"] || $_POST["form_delete"]) {
28 if (!file_exists($patientdir)) mkdir($patientdir);
29 if (!file_exists($imagedir )) mkdir($imagedir );
30 $filename = "$imagedir/$what.jpg";
32 if ($_POST["form_delete"]) {
33 unlink($filename);
35 else {
36 // Check if the upload worked.
38 if (! $errmsg) {
39 if (! is_uploaded_file($_FILES['userfile']['tmp_name']))
40 $errmsg = "Upload failed! Make sure the path/filename is valid " .
41 "and the file is less than 4,000,000 bytes.";
44 // Copy the image to its destination.
46 if (! $errmsg) {
48 /***************************************************************
49 $tmp = exec("/usr/bin/convert -resize 150x150 " .
50 ($_POST["form_normalize"] ? "-equalize " : "") .
51 $_FILES['userfile']['tmp_name'] .
52 " $filename 2>&1");
53 if ($tmp)
54 $errmsg = "This is not a valid image, or its format is unsupported.";
55 ***************************************************************/
57 if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $filename)) {
58 $errmsg = "Internal error accessing uploaded file!";
63 // Write JavaScript for final disposition by the browser.
65 echo "<script LANGUAGE=\"JavaScript\">\n";
66 if ($errmsg) {
67 $errmsg = strtr($errmsg, "\r\n'", " ");
68 echo "window.alert('$errmsg')\n";
69 echo "window.back()\n";
70 } else {
71 echo "opener.location.reload()\n";
72 echo "window.close()\n";
74 echo "</script>\n</body>\n</html>\n";
76 exit;
80 <center>
82 <p><b>Upload Image File</b></p>
84 </center>
86 <form method="post" name="main" action="upload_dialog.php?patientid=<?php echo $patientid ?>&file=<?php echo $what ?>" enctype="multipart/form-data">
87 <input type="hidden" name="MAX_FILE_SIZE" value="4000000">
89 <center>
91 <!-- Table required so input field does not start on a new line -->
92 <table border="0">
93 <tr>
94 <td style="font-size:11pt">
95 Send this file:
96 </td>
97 <td>
98 <input type="file" name="userfile" />
99 </td>
100 </tr>
101 </table>
104 <input type="submit" name="form_submit" value="Upload" />
105 <input type="button" value="Cancel" onclick="window.close()" />
106 <input type="submit" name="form_delete" value="Delete" />
108 </center>
110 </form>
112 </body>
113 </html>