I'm quite new to PHP and trying to upload an image to the server and then write it to the database using a form and php using the code and form below but it doesnt seem to be working for, if I take all of the photo content out the form works perfectly well with the other variables and content such as writing the out the article title and content, would anyone be able to tell me where I'm going wrong at all? thanks in advance guys.
<?php
session_start();
include_once('../php/connection.php');
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'], $_FILES['photo1'])) {
$title = $_POST['title'];
$content = nl2br($_POST ['content']);
$photo1=($_FILES['photo1']);
$target = "../lifestlye";
$target = $target . basename( $_FILES['photo1']);
$query =$pdo->prepare('INSERT INTO article (article_title, article_content, photo_1) VALUES (?,?,?)');
$query->bindValue(1, $title);
$query->bindValue(2, $content);
$query->bindValue(3, $photo1);
$query->execute();
move_uploaded_file($_FILES['photo1'], $target);
{
}
header('Location: index.php');
}
?>
<form action="add.php" method="post" autocomplete="off"/>
<dl class="field four columns centered">
<dd><label for="title">Article Title</label></dd>
<dt class="text"><input type="text" name="title" id="title"/>
</dt>
</dl>
<dl class="field nine columns centered">
<dd><label for="content">Content</label></dd>
<dt class="textarea">
<textarea name="content" id="message"></textarea></dt>
</dl>
<p class="blacktext">Photo</p>
<input type="file" name="photo1">
<input type="submit" id="add article"/>
</form>