title: PHP image upload and write to database
body: <p>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.</p>
  
  <pre><code>&lt;?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-&gt;prepare('INSERT INTO article (article_title, article_content, photo_1) VALUES (?,?,?)');
  
          $query-&gt;bindValue(1, $title);
          $query-&gt;bindValue(2, $content);
          $query-&gt;bindValue(3, $photo1);
  
          $query-&gt;execute();
          move_uploaded_file($_FILES['photo1'], $target);
  {
  
  }
  
  
          header('Location: index.php');
      }
  
      ?&gt;
  
  
  
  
   &lt;form action="add.php" method="post" autocomplete="off"/&gt;
  
  
      &lt;dl class="field four columns centered"&gt;
                      &lt;dd&gt;&lt;label for="title"&gt;Article Title&lt;/label&gt;&lt;/dd&gt;
                      &lt;dt class="text"&gt;&lt;input type="text" name="title" id="title"/&gt;
                      &lt;/dt&gt;
                      &lt;/dl&gt;
                      &lt;dl class="field nine columns centered"&gt;
                  &lt;dd&gt;&lt;label for="content"&gt;Content&lt;/label&gt;&lt;/dd&gt;
                  &lt;dt class="textarea"&gt;
                  &lt;textarea name="content" id="message"&gt;&lt;/textarea&gt;&lt;/dt&gt;
                  &lt;/dl&gt;
                  &lt;p class="blacktext"&gt;Photo&lt;/p&gt;
                  &lt;input type="file" name="photo1"&gt;
                  &lt;input type="submit" id="add article"/&gt;
                  &lt;/form&gt;
  </code></pre>