本文整理汇总了PHP中Photograph::attach_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Photograph::attach_file方法的具体用法?PHP Photograph::attach_file怎么用?PHP Photograph::attach_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photograph
的用法示例。
在下文中一共展示了Photograph::attach_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Photograph
<?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 · Photo Gallery</title>
<?php
require_once '../../includes/header.php';
?>
</head>
<body>
示例2: Photograph
$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">
示例3: output_message
<?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
示例4: sleep
$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);
示例5: join
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>