title: Php file upload is not working
body: <p>I'm trying to upload some images to server. But when i submit the form it will not write the file in the directory. I don't know how to get the exception in php(I'm new to php). </p>
  
  <p>code :</p>
  
  <pre><code>$target = "assets/images/";
  $target = $target . basename( $_FILES['file1']['name']);
  //Writes the file to the server
  if(move_uploaded_file($_FILES['file1']['tmp_name'], $target))
  {
    $uploadRes=true;
    echo "sucess";
  }
  else {
    $uploadRes=false;
    echo "failed";
  }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>Html :</p>
  
  <pre><code> &lt;form class="form-horizontal" id="addpost" method="GET" action="" name="newpost"&gt;
          &lt;div class="control-group"&gt;
              &lt;label class="control-label" for="form-field"&gt;Post Title&lt;/label&gt;
              &lt;div class="controls"&gt;
                  &lt;input type="text" id="form-field" placeholder="Post Title" name="Post_title" value="" /&gt;
               &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="control-group"&gt;
           &lt;label class="control-label" for="form-field-11"&gt;Content Here&lt;/label&gt;
              &lt;div class="controls"&gt;
              &lt;textarea name="post_content"  value="" class="autosize-transition span12" id="form-field-11" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 67px;"&gt;&lt;/textarea&gt;
              &lt;/div&gt;
             &lt;/div&gt;&lt;!-- Insert Image Code --&gt;
             &lt;div class="control-group"&gt;
              &lt;div class="widget-main"&gt;
                  &lt;div class="controls"&gt;
                      &lt;div class="ace-file-input"&gt;
                          &lt;input id="id-input-file-2" type="file" name="file1"&gt;
                          &lt;a class="remove" href="#"&gt;&lt;/a&gt;
                      &lt;/div&gt;
                   &lt;/div&gt;
                   &lt;div class="controls"&gt;
                      &lt;div class="ace-file-input ace-file-multiple"&gt;
                      &lt;input id="id-input-file-3" type="file" multiple="" name="file2"&gt;
                          &lt;a class="remove" href="#"&gt;
                          &lt;i class="icon-remove"&gt;&lt;/i&gt;
                          &lt;/a&gt;
                      &lt;/div&gt;
                      &lt;label&gt;
                      &lt;input id="id-file-format" type="checkbox" name="file-format"&gt;
                          &lt;span class="lbl"&gt; Allow only images&lt;/span&gt;
                      &lt;/label&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
               &lt;/div&gt;&lt;!-- Insert Image Code --&gt;
              &lt;div class="space-4"&gt;&lt;/div&gt;
              &lt;div class="control-group"&gt;
          &lt;label class="control-label" for="form-field-tags"&gt;Tag input&lt;/label&gt;
                  &lt;div class="controls"&gt;
                      &lt;input id="form-field-tags" type="hidden" placeholder="Enter tags ..." value="Tag Input Control" name="tags"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="space-4"&gt;&lt;/div&gt;
              &lt;div class="control-group"&gt;
                  &lt;label class="control-label" for="form-field-select-3"&gt;Select Category&lt;/label&gt;
                  &lt;div class="controls"&gt;
                  &lt;label for="form-field-select-3"&gt;Chosen&lt;/label&gt;
                  &lt;select class="chzn-select" id="form-field-select-3" data-placeholder="Choose a Category..." name="category"&gt;
                  &lt;option value=""&gt;
                  &lt;/option&gt;&lt;option value="Blog"&gt;Blog
                  &lt;/option&gt;&lt;option value="News Letter"&gt;News Letter
                  &lt;/option&gt;&lt;/select&gt;
               &lt;/div&gt;
             &lt;/div&gt;
  
       &lt;div class="control-group" style="float:left; margin-right:25px"&gt;
          &lt;div class="controls"&gt;&lt;button type="submit" class="btn btn-info"&gt;
          &lt;i class="icon-ok bigger-110"&gt;&lt;/i&gt;
          &lt;input type="submit" value="" id="posubmit" style="opacity:0"/&gt;Submit&lt;/button&gt;
          &lt;button type="reset" class="btn"&gt;&lt;i class="icon-undo bigger-110"&gt;&lt;/i&gt;Reset&lt;/button&gt;
          &lt;/div&gt;
       &lt;/div&gt; 
       &lt;div id="resp" style="float:left; margin-top:5px"&gt;
          &lt;img id="loading" style="visibility:hidden;" src="assets/img/ajax-load.gif" width="16" height="16" alt="loading" /&gt;
        &lt;/div&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>I'm submitting the form with ajax..
  Any help would be appreciated.</p>