2 // Copyright (C) 2009-2010 Rod Roark <rod@sunsetsystems.com>
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";
19 <title
>Upload Image
</title
>
20 <link rel
="stylesheet" href
="<?php echo xl($css_header,'e');?>" type
="text/css">
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"]) {
36 // Check if the upload worked.
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.
48 /***************************************************************
49 $tmp = exec("/usr/bin/convert -resize 150x150 " .
50 ($_POST["form_normalize"] ? "-equalize " : "") .
51 $_FILES['userfile']['tmp_name'] .
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";
67 $errmsg = strtr($errmsg, "\r\n'", " ");
68 echo "window.alert('$errmsg')\n";
69 echo "window.back()\n";
71 echo "opener.location.reload()\n";
72 echo "window.close()\n";
74 echo "</script>\n</body>\n</html>\n";
82 <p
><b
>Upload Image File
</b
></p
>
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">
91 <!-- Table required so input field does not start on a
new line
-->
94 <td style
="font-size:11pt">
98 <input type
="file" name
="userfile" />
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" />