Example #1
0
 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 IMAGES WITH "SPECIFIC" TYPE, NAME, UPLOAD DIR.
     * 
     * This will upload ONLY the image types specified in the 'fileTypes()' method.
     * In this case, the image to be uploaded will be 'gif', it will be uploaded to
     * a folder called 'documents' or it'll be created if it does not exist 
     * and the image will be re-named  to 'awesome.gif'
     */
    if ($_FILES) {
        echo $bulletProof->uploadDir("documents")->fileTypes(array('gif'))->upload($_FILES["picture"], "awesome");
    }
    /* Always use the try/catch block to handle errors */
} catch (\ImageUploader\ImageUploaderException $e) {
    echo $e->getMessage();
/**
 * 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();
/**
 * 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 {
    /**
     * ADD A WATERMARK TO IMAGE
     * 
     * This will add a watermark as specified in the 'watermark()' method. 
     * The first argument should always be the image and the second
     * should be the position (where to put the watermark). You can only pass 
     * 4 types of positions: 
     * top-right, bottom-right, center, 'top-left', 'bottom-left'
     *
     * This position obviously determines where the watermark appears in the image.
     * 
     */
    if ($_FILES) {
        echo $bulletProof->fileTypes(array("gif", "jpg", "jpeg", "png"))->uploadDir("watermark")->limitSize(array("min" => 1, "max" => 52000))->watermark("logo.png", "bottom-left")->upload($_FILES['picture']);
/**
 * 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 {
    /**
     * SIMPLE & DEFAULT UPLOAD
     *
     * This is the simplest way to upload an image. It will use the default methods of the class. 
     * Which means it will: 
     * > upload an image with (jpg, png, gif, jpeg) extensions only. 
     * > It will only upload file with sizes in-between 1Kb to 30Kb. 
     * > It will upload the images in a folder called "uploads", if you don't have such folder
     *   then it will be created with permission/chmod of '666'. 
     * > Uploaded image will also be given a unique & random name
     */
    if ($_FILES) {
        echo $bulletProof->upload($_FILES['picture']);
    }
<?php

/**
 * 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 {
    /**
     * RESIZE IMAGES BY PIXELS. 
     *
     * This simply will shrink the image, to the given size in the 'shrink()' method 
     */
    if ($_FILES) {
        echo $bulletProof->fileTypes(array("gif", "jpg", "jpeg", "png"))->limitSize(array("min" => 1, "max" => 2122000))->shrink(array("width" => 30, "height" => 30))->upload($_FILES['picture']);
    }
    /* Always use the try/catch block to handle errors */
} catch (\ImageUploader\ImageUploaderException $e) {
    echo $e->getMessage();
}
/**
 * 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 {
    /**
     * CROP IMAGES BY PIXELS. 
     * 
     * This will crop all images as specified in the 'crop()' method. 
     * Unless the the crop size is bigger than the actual image. In other words: 
     * If you have an image with 100px * 100px, if you want to crop it to 120px * 120px 
     * you can't and you shouldn't. (Or perhaps, extend the class and add your own method)
     *
     * The script will calculate the ratio and crop the image always from the center of the image. 
     * 
     */
    if ($_FILES) {
        echo $bulletProof->fileTypes(array("gif", "jpg", "jpeg", "png"))->crop(array("width" => 100, "height" => 100))->upload($_FILES['picture']);
    }