Exemple #1
0
<?php

require_once "../../includes/initialize.php";
if (!$session->is_logged_in()) {
    redirect_to("login.php");
} else {
    $user = User::find_by_id($_SESSION['user_id']);
}
if (isset($_POST['submit'])) {
    $photo = new Photograph();
    $photo->caption = $_POST['caption'];
    $photo->attach_file($_FILES['file_upload']);
    if ($photo->save()) {
        $session->message("Success! The photo was uploaded successfully. ");
        redirect_to('list_photos.php');
    } else {
        $message = join("<br />", $photo->errors);
    }
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
  	<title>Photo Upload &middot; Photo Gallery</title>
    <?php 
require_once '../../includes/header.php';
?>
  </head>

  <body>
Exemple #2
0
$message1 = "";
$message2 = "";
$message3 = "";
$message4 = "";
if (isset($_POST['submit'])) {
    $photo = new Photograph();
    $photo->hotel_id = $hotel->id;
    $photo->attach_file($_FILES['upload_file']);
    if ($photo->save()) {
        $message1 = "Photographs was successfully uploaded";
    } else {
        $message1 = join("<br>", $photo->errors);
    }
    $photo1 = new Photograph();
    $photo1->hotel_id = $hotel->id;
    $photo1->attach_file($_FILES['upload_file1']);
    if ($photo1->save()) {
        $message2 = "Photographs was successfully uploaded";
    } else {
        $message2 = join("<br>", $photo1->errors);
    }
}
?>
<!DOCTYPE html>
<html>
<head>
	<title>
		Hotel
	</title>
	<link rel="stylesheet" type="text/css" href="../css/reset.css">
	<link rel="stylesheet" type="text/css" href="../css/hotel.css">
<?php

require_once '../../includes/initialize.php';
if (!$session->is_logged_in()) {
    redirect("login.php");
}
$max_file_size = 1048576;
if (isset($_POST['submit'])) {
    $photo = new Photograph();
    $photo->caption = $_POST['caption'];
    $photo->attach_file($_FILES['upload_file']);
    if ($photo->save()) {
        $session->set_get_message("Photograph Uploaded Successfully");
        redirect('view_photograph.php');
    } else {
        $message .= "<br />" . join("<br />", $photo->errors);
    }
}
include_layout_template("admin_header.php");
echo output_message($message);
?>
	<h2>Photo Upload</h2>
	<form action="photo_upload.php" enctype="multipart/form-data" method="post" >
		<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
		<p><input type="file" name="upload_file" value="" /></p>
		<p>Caption : <input type="text" name ="caption" value="" /></p>
		<p><input type="submit" name="submit" /></p>
	</form>


<?php 
$photograph_details = $photograph->find_by_id($session->applicant_id);
if ($_FILES['picture']['error'] == 2) {
    sleep(2);
    echo '<h4 class="alert alert-error">Error</h4>';
    echo '<hr>';
    echo "Maximum File size Exceeded(250Kb)";
    die;
}
if (!empty($photograph_details) && !empty($_FILES['picture']['name'])) {
    $photograph->image_id = $photograph_details->image_id;
    unlink(SITE_ROOT . DS . 'passport' . DS . $photograph_details->filename);
}
$arrayfiledetails = explode('.', $_FILES['picture']['name']);
$extension = $arrayfiledetails[sizeof($arrayfiledetails) - 1];
$_FILES['picture']['name'] = $session->applicant_id . '.' . $extension;
if ($photograph->attach_file($_FILES['picture'])) {
    $photograph->caption = User::applicant_fullname($session->applicant_id);
    $photograph->applicant_id = $session->applicant_id;
    //explode filename to get file extension
    $photograph->filename = $_FILES['picture']['name'];
    if ($photograph->save()) {
        $user = new User();
        $user->applicant_id = $session->applicant_id;
        $user->updateProgress('G');
        sleep(2);
        echo '<h4 class="alert alert-success"><i class="iconic-o-check" style="color: #51A351"></i> Success</h4>';
        echo '<hr>';
        echo 'Your <span style=" font-weight: bold; text-shadow: 1px 1px 4px #51A351;">Passport</span> has been successfully uploaded';
        echo '<br><hr>';
    } else {
        sleep(2);
Exemple #5
0
    if ($photo->save()) {
        $message1 = "Photographs was successfully uploaded";
    } else {
        $message1 = join("<br>", $photo->errors);
    }
    $photo1 = new Photograph();
    $photo1->hotel_id = $_GET['id'];
    $photo1->attach_file($_FILES['upload_file1']);
    if ($photo1->save()) {
        $message2 = "Photographs was successfully uploaded";
    } else {
        $message2 = join("<br>", $photo1->errors);
    }
    $photo2 = new Photograph();
    $photo2->hotel_id = $_GET['id'];
    $photo2->attach_file($_FILES['upload_file2']);
    if ($photo2->save()) {
        $message3 = "Photographs was successfully uploaded";
    } else {
        $message3 = join("<br>", $photo1->errors);
    }
}
?>

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>