Exemplo n.º 1
0
if (!$session->is_logged_in()) {
    redirect_to("login.php");
}
$max_file_size = 1048576;
// expressed in bytes
//     10240 =  10 KB
//    102400 = 100 KB
//   1048576 =   1 MB
//  10485760 =  10 MB
if (isset($_POST['submit']) && $_FILES['file_upload']['size'] != 0 && $_FILES['file_upload2']['size'] != 0) {
    $photo = new Photograph();
    $photo->attach_file($_FILES['file_upload']);
    $photo->description = $_POST['description'];
    $photo->category = $_POST['category'];
    $photo2 = new Photograph2();
    $photo2->attach_file($_FILES['file_upload2']);
    $photo2->category = $_POST['category'];
    if ($photo->save() && $photo2->save()) {
        // Success
        $session->message("Photographs uploaded successfully.");
        redirect_to('index.php');
    } else {
        // Failure
        $message = join("<br />Errror", $photo->errors);
    }
}
?>

<!DOCTYPE html>
<html>
    <head>