title: upload file with progresss bar and delete option in php
body: <p>I am creating file uploader with showing progress bar and the close button but there are some major problems with these code.it shows the progress bar continuesly.and the main problem is it delete the file but then after it refresh the page and my all uploaded files are not visible to me from which i want to delete some file.
   i just want to creator file downloader like gmail provides the facility of multiple file attachment at same time with progress bar and close button for the file which uploaded by mistak by the user.</p>
  
  <pre><code>    &lt;script&gt;
       $(document).ready(function() { 
  
                  $('#photoimg').die('click').live('change', function()
                  { 
                             //$("#preview").html('');
  
                      $("#imageform").ajaxForm({target: '#preview', 
                           beforeSubmit:function(){ 
  
                          console.log('ttest');
                          $("#imageloadstatus").show();
                           $("#imageloadbutton").hide();
                           }, 
                          success:function(){ 
                          console.log('test');
                           $("#imageloadstatus").hide();
                           $("#imageloadbutton").show();
                          }, 
                          error:function(){ 
                          console.log('xtest');
                           $("#imageloadstatus").hide();
                          $("#imageloadbutton").show();
                          } }).submit();
  
  
                  });
              }); 
      &lt;/script&gt;
  
      &lt;div class="wrap"&gt;
      &lt;?php
      /**
      * Multi file upload example
      * @author Resalat Haque
      * @link http://www.w3bees.com/2013/02/multiple-file-upload-with-php.html
      **/
  
      if(isset($_POST['submit']))
      {
      $valid_formats = array("jpg", "png", "gif", "zip", "bmp","doc","docx");
      $max_file_size = 1024*100; //100 kb
      $path = "uploads/"; // Upload directory
      $count = 0;
  
      if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
          // Loop $_FILES to execute all files
          foreach ($_FILES['files']['name'] as $f =&gt; $name) {     
              if ($_FILES['files']['error'][$f] == 4) {
                  continue; // Skip file if any error found
              }          
              if ($_FILES['files']['error'][$f] == 0) {              
                  if ($_FILES['files']['size'][$f] &gt; $max_file_size) {
                      $message[] = "$name is too large!.";
                      continue; // Skip large files
                  }
                  elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
                      $message[] = "$name is not a valid format";
                      continue; // Skip invalid file formats
                  }
                  else{ // No error found! Move uploaded files 
                      if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name)) {
                                  $path="uploads/".$name;
                                  ?&gt;
                                  &lt;div id='imageloadstatus' style='display:none'&gt;&lt;/div&gt;
      &lt;div id='imageloadbutton'&gt;
      &lt;script type="text/javascript"&gt;
      &lt;?php           
                      echo "&lt;a href=\"dl.php?file=".$name."\"&gt;".$name."&lt;/a&gt;&amp;nbsp;&lt;a href=\"dl.php?file=".$name."\" &gt;                          &lt;img src='image/loader.gif' alt='Uploading....'/&gt;&lt;img src=\"image/close.jpg\" /&gt;&lt;/a&gt;&lt;br /&gt;"; 
                          $count++; // Number of successfully uploaded files
                      }
                  }
              }
          }
      }
      ?&gt;
              &lt;?php
              # error messages
              if (isset($message)) {
                  foreach ($message as $msg) {
                      printf("&lt;p class='status'&gt;%s&lt;/p&gt;&lt;/ br&gt;\n", $msg);
                  }
              }
              # success message
  
              if($count !=0){
                  printf("&lt;p class='status'&gt;%d files added successfully!&lt;/p&gt;\n", $count);
              }
              ?&gt;
              &lt;br /&gt;
      &lt;?php } ?&gt;      
              &lt;!doctype html&gt;
      &lt;html lang="en"&gt;
        &lt;head&gt;
  
         &lt;style type="text/css"&gt;
            /* Style goes here */ 
          &lt;/style&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
              &lt;!-- Multiple file upload html form--&gt;
              &lt;form action="upload_demo.php" method="post" enctype="multipart/form-data" id="imageform"&gt;
  
      &lt;div id='preview'&gt;
      &lt;/div&gt;
  
                  &lt;input type="file" name="files[]" multiple="multiple" id="photoimg"&gt;
                  &lt;input type="submit" value="Upload" name='submit'&gt;
  
  
              &lt;/form&gt;
      &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>file to delete dl.php</p>
  
  <pre><code>    &lt;?php if(isset($_GET['file']))
              {
                  $file=$_GET['file'];
                  $path="uploads/".$file;
                  unlink($path);
                 // echo "The file: ".$file." has been deleted.";
              ?&gt;
              &lt;script&gt; window.location.href = "upload_demo.php";          
              &lt;/script&gt;
              &lt;?php
              }  ?&gt;
  </code></pre>