Esempio n. 1
0
     $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>';
         }
     }
     //wenn beides validiert werden konnte wird das bild gespeichert
     if ($validation->passed() && $validation->filePassed()) {
         $eventFileName = $fileSaver->savePicture($_FILES, 'eventPicture');
         try {
             //name des alten bildes wird abgerufen um es später löschen zu können
             $old = $db->get('event', array('id', '=', Input::get('eventId')))->first()->picture;
             //name des neuen bildes wird in die db gespeichert
             $db->update('event', Input::get('eventId'), array('picture' => $eventFileName, 'picturedescription' => Input::get('eventPictureDescription')));
             //altes bild wird gelöscht
             unlink(Config::get('pictures/dirOriginal') . $old);
             Session::flash('success', 'EventPicture successfully changed');
             Redirect::to('admin.php');
         } catch (Exception $e) {
             echo 'something went terrible wrong<br>';
             die($e->getMessage());
         }
     }
 }
Esempio n. 2
0
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) {
            echo $error, '<br>';
        }
    }
}
?>

<?php