I have been grinding my teeth over this one for awhile now, I'm trying to make an input field that will allow users to create a picture album
<!DOCTYPE html>
<?php
require_once 'core/init.php';
ob_start();
?>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en-US">
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Insert Your Site Description" />
<title>Dunnikier Country Park</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Fav Icon -->
<link rel="shortcut icon" href="assets/ico/fav_icon.ico">
<link rel="apple-touch-icon" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<!-- CSS -->
<link href="assets/css/styles.css" rel="stylesheet"> <!-- Custom -->
<link href="assets/css/elegant_font.css" rel="stylesheet"> <!-- Elegant Font -->
<link href="assets/css/nivo-slider.css" rel="stylesheet" media="screen" /> <!-- Nivo Slider -->
<link rel="stylesheet" type="text/css" href="assets/css/tooltipster.css" />
<!-- Google Fonts -->
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,300italic,400italic,700italic' rel='stylesheet' type='text/css'>
<!-- Scripts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <!-- jQuery Core -->
<script src="assets/js/jquery.nivo.slider.js" type="text/javascript"></script> <!-- Nivo Slider -->
<script src="assets/js/custom.js"></script> <!-- Custom JavaScript -->
<script src="assets/js/scroll-startstop.events.jquery.js"></script>
<script src="assets/js/jquery.jscrollpane.js"></script>
<script src="assets/js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="assets/js/jquery.tooltipster.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://css3-mediaqueries-js.googlecode.com/files/css3-mediaqueries.js"></script>
<![endif]-->
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
<script>
$(document).ready(function() {
$('.tooltip').tooltipster();
});
</script>
<script>
$(document).ready(function(){
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
});
});
</script>
</head>
<body>
<div id="panel">
<?php include 'login.php'?>
</div>
<p class="slide"><a href="#" class="btn-slide">Login</a></p>
<header>
<div class="logo">
<a href="index.html"></a>
</div>
<div class="navigation">
<ul>
<li><a href="index.php" class="icon_house_alt tooltip" title="Go home">
</a></li>
<li><a href="about.php" class="icon_document_alt tooltip" title="About Us">
</a></li>
<li><a href="gallery.php" class="icon_image tooltip" title="Gallery">
</a></li>
<li><a href="contact.php" class="icon_mail_alt tooltip" title="Contact Us">
</a></li>
</ul>
</div>
</header>
<section class="nivoSlider" id="slider">
<img src="assets/img/pond.jpg" data-thumb="images/toystory.jpg" alt="" data-transition="slideInLeft" title="Dunnikier Parks frozen pond"/>
<img src="assets/img/penguins.jpg" data-thumb="images/up.jpg" alt="" data-transition="slideInLeft" title="Penguins in Dunnikier park"/>
</section>
<section class="content">
<div class="col-1">
<h2>Links</h2>
<hr><br />
<ul id="links">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="gallery.php">Gallery</a></li>
<li><a href="minutes.php">Minutes</a></li>
<li><a href="events.php">Events</a></li>
<li><a href="news.php">News</a></li>
<li><a href="history.php">History</a></li>
<li><a href="contact.php" title="info.php">Contact</a></li>
<li><?php
$user = new User();
if($user->isLoggedIn()){ ?>
<li><a href="Admin.php" title="Admin">Admin</a></li>
<?php }?>
</a></li>
<?php
?>
<a href="links.php" id="link">Useful links</a>
</ul>
</div>
<div class="center">
<div class="col-2">
<h2>Dunnikier Country Park</h2>
<?php
if(Session::exists('home')){
echo '<p>' . Session::flash('home', 'You have been registered and can now log in!') . '</p>';
}
$user = new User();
if($user->isLoggedIn()){
echo'</a> <br /></p>';
try{
$db = new PDO("mysql:host=localhost;dbname=oopdatabase", 'root', '');
$db ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e){
echo $e->getMessage();
die(); }
?>
<hr><br />
<div id ="userNavagtion">
<br />
<div>
<?php if($user->hasPermission('admin')){ ?>
<p><a href ="adminupload.php">Image upload</a></p>
<p><a href ="minutesupload.php">Minutes upload</a></p>
<a href ="">
<ul>
<li> <a href="admin.php">Admin home</a></li>
<li> <a href="logout.php">Log out</a></li>
</ul>
<?php } ?> </a>
<h3>Image upload</h3>
<?php
if(isset($_POST['btn_upload']))
{
$filetmp = $_FILES["file_img"]["tmp_name"];
$filename = $_FILES["file_img"]["name"];
$filetype = $_FILES["file_img"]["type"];
$filesize = $_FILES["file_img"]["size"];
$dirName = $_POST['dirName'];
$filepath = "test/".$dirName;
if (!file_exists($filepath) ) {
mkdir($filepath);
}
if($filetmp == "")
{
echo "please select a photo";
}
else
{
if($filesize > 2097152)
{
echo "photo > 2mb";
}
else
{
if($filetype != "image/jpeg" && $filetype != "image/png" && $filetype != "image/gif")
{
echo "Please upload jpg / png / gif";
}
else
{
if (!move_uploaded_file($filetmp, $filepath)) {
echo "error uploading file" . $filetmp;
} else {
move_uploaded_file($filetmp,$filepath);
$filepath.'/'.basename($_FILES['name']['tmpname']);
echo $filetmp . " uploaded to " . $filepath;
// sql stuff
$sql = "INSERT INTO upload_img (`img_name`, `img_path`, `img_type`);
VALUES (:filename, :filepath, :filetype);
";
$query = $db->prepare($sql);
$query->execute(array(
':filename'=> $filename,
':filepath'=> $filepath,
':filetype'=> $filetype
));
echo 'Upload complete';
}
}
}
}
?>
<div id ="imgHolder">
<?php
$user = new User();
if($user->isLoggedIn()){
?>
</div>
<form action="" method="post" enctype="multipart/form-data">
<div>
<input type="file" name="file_img" />
<input type="text" name="dirName" />
</div>
</div>
<input type="hidden" name="token" value="<?php echo Token::generate();?>">
<input type="submit" name="btn_upload" value="Upload">
</form>
</div>
<?php } ?>
</div>
</div>
<?php
} else {
Redirect::to('index.php');
}
?>
<p></p>
</div>
</div>
<div class="col-1">
<h2>Contact</h2>
<hr><br />
<form name="quickCon" action="mailto:JLMCLR@hotmail.com?Subject=Message%20from%20website" method="post">
<input type="text" name="name" placeholder="Enter Name..."/>
<input type="text" name="email" placeholder="Enter Email..."/>
<textarea name="message" placeholder="Enter Message..."></textarea>
<div id="captcha">
</div>
<button type="submit" name="submit">Send</button>
</form>
</div>
</section>
<footer>
<div class="addr">
<span>Address:</span>
<p>Dunnikier Park,<br />Kirkcaldy,<br />Fife,<br />KY1 3LP</p>
</div>
<div class="external">
<ul>
<li><a href="http://www.digitalfife.com/" class="tooltip" title="Digital Fife"><img src="assets/img/digital-fife.png" alt="Link to digital fife"/></a></li>
<li><a href="https://www.facebook.com/pages/Dunnikier-Country-Park-Kirkcaldy-Development-Group/707802639250313?fref=ts" class="tooltip" title="Facebook"><img src="assets/img/facebook.png" alt="Link to facebook"/></a></li>
<br />
<p>© Copyright 2015 | Dunnikier country club</p>
</ul>
</div>
</footer>
</body>
</html>
I included the full file encase I missed something .
Current errors:
Warning: mkdir(): File exists in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\DesktopSitev2.1\adminupload.php on line 189
Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\DesktopSitev2.1\adminupload.php on line 211
Warning: move_uploaded_file(): Unable to move 'E:\EasyPHP-DevServer-14.1VC11\binaries\tmp\phpF0D3.tmp' to 'test/KEVIN' in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\DesktopSitev2.1\adminupload.php on line 211
error uploading fileE:\EasyPHP-DevServer-14.1VC11\binaries\tmp\phpF0D3.tmpUpload complete