コード例 #1
0
ファイル: changePicture.php プロジェクト: Geryones/eventCal
 *
 * hier wird das wechseln von einem event-bild verwaltet
 */
require_once 'includes/overall/header.php';
/*
 * nur ein admin kann das machen
 */
if ($user->isLoggedIn()) {
    echo '<br><br>';
    if (!is_null($_POST['id'])) {
        $updateId = $_POST['id'];
        $_POST = array();
    }
    $db = DB::getInstance();
    $event = $db->get('event', array('id', '=', $updateId))->first();
    $fileSaver = new SaveFile();
    $validation = new Validate();
    if (Input::exists()) {
        //regeln für das bild
        $validation->checkFile($_FILES, array('eventPicture' => array('name' => 'Picture', 'type' => 'picture', 'required' => true, 'maxFileSize' => 512 * 1000, 'maxWidth' => 1000, 'maxHeight' => 1000)));
        //regeln für die picture-description
        $validation->check($_POST, array('eventPictureDescription' => array('name' => 'Description of the EventPicture', 'required' => true, 'max' => 255)));
        if (!$validation->passed()) {
            foreach ($validation->errors() as $error) {
                echo $error . '<br>';
            }
        }
        if (!$validation->filePassed()) {
            foreach ($validation->fileErrors() as $error) {
                echo $error . '<br>';
            }
コード例 #2
0
 */
?>

    <h1>This is upload</h1>
<?php 
$user = new User();
//Wenn ein Bild / datei ausgesucht wurde
if (Input::exists()) {
    // echo 'check.. input exists <br>';
    $validate = new Validate();
    //bild wird validiert
    $validate->checkFile($_FILES, array('fileUpload' => array('name' => 'Picture', 'type' => 'picture', 'required' => true, 'maxFileSize' => 3072 * 1000, 'maxWidth' => 4000, 'maxHeight' => 4000, 'minWidth' => 400, 'minHeight' => 400)));
    $validate->check($_POST, array('description' => array('name' => 'Picture Description', 'required' => true, 'min' => 5, 'max' => 1000)));
    //falls validierung erfolgreich war
    if ($validate->passed() && $validate->filePassed()) {
        $saver = new SaveFile();
        //echo 'file upload validation passed<br>';
        //echo ' dir erstellt <br>';
        //wem gehört das bild?
        $owner = $user->data()->id;
        // echo 'owner ermittelt '.$owner.'<br>';
        //bild wird gespeichert
        if ($saver->savePicture($_FILES, 'fileUpload', $owner, Input::get('description'))) {
            //Session::flash('picUpload','Your picture was successfully saved');
            //Redirect::to('index.php');
            echo 'upload successful<br>';
        } else {
            echo ' there was an error.. we are sorry <br>';
        }
    } else {
        foreach ($validate->errors() as $error) {