function AddAttach($FILES, $myMessageId) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/Main.php"; require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/HelpDesk.php"; require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Language/{$MainLanguage}/HelpDesk.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/ImageUploader.class.php"; $bulletProof = new ImageUploader\BulletProof(); $db = $this->db; $acc = $this->acc; $return = ""; foreach ($FILES["file"]["error"] as $id => $valor) { if ($FILES["file"]["name"][$id] != "") { $name = $FILES["file"]["name"][$id]; $name = strtolower($name); $array = explode(".", $name); $nr = count($array); $ext = $array[$nr - 1]; $allowedExtensions = explode(",", $HelpDeskAllowedExt); $fileOriName = htmlentities($FILES['file']['name'][$id]); if (in_array($ext, $allowedExtensions)) { $fileNewName = md5(date("Y-m-d H:i:s")) . $id; try { $image = $bulletProof->limitSize(array("min" => 512, "max" => 3145728))->limitDimension(array("height" => 3000, "width" => 3000))->uploadDir("./{$HelpDeskUploadDir}")->upload($FILES['file'], $fileNewName, $id); } catch (\ImageUploader\ImageUploaderException $e) { echo $e->getMessage(); } if (isset($image) && $image != false) { $fileNewName .= "." . $ext; $db->Query("INSERT INTO Z_HelpDeskAttach (msg_idx, [file], orig_name) VALUES ('{$myMessageId}', '{$fileNewName}', '{$fileOriName}')"); } else { $return .= "<br />{$HelpDeskMessage22} {$fileOriName}"; } /*if (move_uploaded_file($FILES['file']['tmp_name'][$id], $uploadFile)) { $db->Query("INSERT INTO Z_HelpDeskAttach (msg_idx, [file], orig_name) VALUES ('$myMessageId', '$fileNewName', '$fileOriName')"); } else { $return .= "<br />$HelpDeskMessage22 $fileOriName"; }*/ } else { $return .= "<br />{$HelpDeskMessage22} {$fileOriName} {$HelpDeskMessage26}"; } } } return $return; }
* BULLETPROOF - ALL IN ONE, IMAGE UPLOAD/MANIPULATE. * * @category BULLETPROOF * @license Free / Luke 3:11 * @version 1.0.0 * @link https://github.com/bivoc/bulletproof * @author bivoc. ~ The force is strong with this one. * */ // Require the main src file. require_once "../src/BulletProof.php"; // Require the HTML form. require_once "form.html"; // Create an instance of BulletProof $bulletProof = new ImageUploader\BulletProof(); try { /** * UPLOAD WITH A SPECIFIC SIZE * * This will check the size of the image (in bytes), as specified in the 'limitSize()' method. * Pass values in bytes, and don't forget "min", "max". * remember. 1 kb ~ 1000 bytes. In this example, only an image less than 42Kb can be uploaded * */ if ($_FILES) { echo $bulletProof->limitSize(array("min" => 1, "max" => 42000))->upload($_FILES['picture'], "cars_picture"); } /* Always use the try/catch block to handle errors */ } catch (\ImageUploader\ImageUploaderException $e) { echo $e->getMessage(); }