protected function _upload_form()
 {
     $this->addScript("js/functions.js");
     $this->addScript("js/behaviour.js");
     $this->addScript("js/advajax.js");
     $this->addScript("js/ajax.js");
     $this->addScript("js/category-tree.js");
     $this->addScript("js/upload-form.js");
     $this->setTemplateVar('upload_action', $this->url('upload-form'));
     if (!empty($_POST['submit'])) {
         $cids = Utils::pg('cid');
         if (!is_array($cids)) {
             $cids = explode(',', $cids);
         }
         $photo = new Photo();
         $photo->setDBData('photo_description', Utils::p('description'));
         $photo->setDBData('photo_title', Utils::p('title'));
         $photo->upload($_FILES['file'], $cids);
     }
 }
require_once "includes/smarty.php";
require_once "includes/utils.php";
require_once "includes/photo.php";
$session = Session::singletone();
if ($session->requireLogin()) {
    exit;
}
HTML::startHTML();
HTML::head(_UPLOAD_PHOTO);
HTML::startBODY();
$smarty = new Phph_Smarty(_UPLOAD_PHOTO);
$ref = Utils::pg("ref");
if (isset($_POST['submit'])) {
    try {
        $photo = new Photo();
        $photo->upload($_FILES['file'], $_POST['title'], $_POST['description'], $_POST['cid']);
    } catch (Exception2 $e) {
        $smarty->assign('error', 1);
        $smarty->assign('error_title', $e->getMessage());
        $smarty->assign('error_description', $e->getDescription());
    }
}
$smarty->assign('l_upload', _UPLOAD);
$smarty->assign('l_file', _FILE);
$smarty->assign('l_title', _TITLE);
$smarty->assign('l_description', _DESCRIPTION);
$smarty->assign('l_category', _CATEGORY);
$smarty->assign('max_file_size', Config::get("max_file_size") * 1024);
$smarty->assign('ref', $ref);
function fill_category_tree(&$categories, $ccid, $level)
{
Beispiel #3
0
<?php

/**
 * Created by PhpStorm.
 * User: Engr. Naveed
 * Date: 2/6/2015
 * Time: 6:10 PM
 */
require_once __DIR__ . "/" . "../initialize.php";
if (isset($_FILES['photoInput']) & isset($_POST['person_id'])) {
    $inputFile = 'photoInput';
    $uploadDir = "../photos";
    $targetName = $_POST['person_id'] . ".jpg";
    $photo = new Photo();
    if ($photo->upload($inputFile, $targetName, $uploadDir)) {
        $photo->resizeImage($photo->destination, $photo->destination, 210, 260);
        echo "Photo uploaded successfully.";
    } else {
        echo $photo->error;
    }
}