$message = ''; if (isset($_POST['submit'])) { $photo = $_FILES['photo']; if ($photo && !$photo['error']) { $name = $photo['name']; $type = $photo['type']; $path = $photo['tmp_name']; $bytes = file_get_contents($path); $fName = trim($_POST['fName']); $mName = trim($_POST['mName']); $lName = trim($_POST['lName']); $id = trim($_POST['id']); $course = trim($_POST['COURSE']); $yr = trim($_POST['YR']); add_student($id, $fName, $mName, $lName, $course, $yr, 1); add_photo($id, $name, $type, $bytes, 'student', 1); add_sitinDetails($id, 0, 30); //Sit-in details for student is added $target = "../uploadedPhotos/"; $target = $target . basename($_FILES['photo']['name']); if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } $message = "<div class = 'alert alert-success' style = 'width: 265px;'>Successfully added.</div>"; echo "<script>"; //go back to viewPhotos page after 3 seconds. echo "setTimeout(function(){ document.location = '?p=viewStudent'; }, 2000);"; echo "</script>"; } else { $message = "<div class = 'alert alert-warning' style = 'width: 265px;'>Photo is invalid!</div>"; }
$author = $_SESSION['uid']; $upload = date("Y-m-d H:i"); $update = date("Y-m-d H:i"); $json = get_option('stor'); $stor = json_decode($json); $i = 0; // 2143289344 = 2GB*1024*1024*1024 - 4MB*1024*1024 while ($storage->getDomainCapacity($stor[$i]) > 2143289344) { $i++; } $domain = $stor[$i]; $storage->upload($domain, 'original/' . $name, $_FILES['file']['tmp_name']); if ($storage->errno == 0) { // 生成缩略图 $img_data = $storage->read($domain, 'original/' . $name); $img_info = getimagesize($_FILES['file']['tmp_name']); $width = $img_info[0]; $height = $img_info[1]; add_photo($author, $name, $title, $filesize, $width, $height, $upload, $update, $domain, '1'); $uid = get_photo_info($name, 'uid', 'name'); $url = photo_link($uid); header("Location: {$url}"); exit; } } else { header("refresh:1;url=" . SITE_URL . "upload.php"); echo '你提交的不是图片...'; exit; } } }
$message = ''; if (isset($_POST['submit'])) { $photo = $_FILES['photo']; if ($photo && !$photo['error']) { $name = $photo['name']; $type = $photo['type']; $path = $photo['tmp_name']; $bytes = file_get_contents($path); $fName = trim($_POST['fName']); $mName = trim($_POST['mName']); $lName = trim($_POST['lName']); $id = trim($_POST['id']); $pass = trim($_POST['pass']); add_admin($id, $fName, $mName, $lName, 1); add_account($id, $pass, 'admin'); add_photo($id, $name, $type, $bytes, 'admin', 1); $target = "../uploadedPhotos/"; $target = $target . basename($_FILES['photo']['name']); if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } $message = "<div class = 'alert alert-success' style = 'width: 265px;'>Successfully added.</div>"; echo "<script>"; //go back to viewPhotos page after 3 seconds. echo "setTimeout(function(){ document.location = '?p=manageAdmin/viewAdmin'; }, 2000);"; echo "</script>"; } else { $message = "<div class = 'alert alert-warning' style = 'width: 265px;'>Photo is invalid!</div>"; } } ?>
$type = $photo['type']; $path = $photo['tmp_name']; $bytes = file_get_contents($path); $fName = trim($_POST['fName']); $mName = trim($_POST['mName']); $lName = trim($_POST['lName']); $id = trim($_POST['id']); $course = trim($_POST['COURSE']); $yr = trim($_POST['YR']); $lab = trim($_POST['lab']); $days = trim($_POST['days']); $time = trim($_POST['time']); $pass = trim($_POST['pass']); add_working($id, $fName, $mName, $lName, $course, $yr, 1, $lab, $time, $days, date("y-m-d")); add_account($id, $pass, 'working scholar'); add_photo($id, $name, $type, $bytes, 'working scholar', 1); $target = "../uploadedPhotos/"; $target = $target . basename($_FILES['photo']['name']); if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } $message = "<div class = 'alert alert-success' style = 'width: 265px;'>Successfully added.</div>"; echo "<script>"; //go back to viewPhotos page after 3 seconds. echo "setTimeout(function(){ document.location = '?p=viewWorking'; }, 2000);"; echo "</script>"; } else { $message = "<div class = 'alert alert-warning' style = 'width: 265px;'>Photo is invalid!</div>"; } } ?>
<?php $message = ''; if (isset($_POST['upload'])) { $photo = $_FILES['photo']; if ($photo && !$photo['error']) { $name = $photo['name']; $type = $photo['type']; $path = $photo['tmp_name']; $bytes = file_get_contents($path); add_photo($name, $type, $bytes); $msg = "<div class = 'alert alert-success' style = 'width: 265px;'>New photo has been uploaded.</div>"; echo "<script>"; //go back to viewPhotos page after 3 seconds. echo "setTimeout(function(){ document.location = '?p=viewAdmin'; }, 2000);"; echo "</script>"; } else { $msg = "<div class = 'alert alert-warning' style = 'width: 265px;'>Invalid File!</div>"; } } $photos = get_photos(); ?> <html> <body> <div class="container"> <div class="row col-md-4"> <div class="box"> <form method="post" enctype="multipart/form-data"> <div class="form-group"> <input type="file" name="photo" />