title: Ignore Empty instances of File upload With Zend Framework ? File not uploading because of it
body: <p>I am trying to upload several files in ZF1</p>
  
  <p>There are two options to upload; audio or an image. When I attempt to upload images only the empty instance of file_audio is having issues.</p>
  
  <p>This is my print $_FILES</p>
  
  <pre><code>Array
  (
      [image_file] =&gt; Array
          (
              [name] =&gt; boss.jpg
              [type] =&gt; image/jpeg
              [tmp_name] =&gt; C:\WINDOWS\Temp\phpA01.tmp
              [error] =&gt; 0
              [size] =&gt; 37246
              [options] =&gt; Array
                  (
                      [ignoreNoFile] =&gt; 
                      [useByteString] =&gt; 1
                      [magicFile] =&gt; 
                      [detectInfos] =&gt; 1
                  )
  
              [validated] =&gt; 
              [received] =&gt; 
              [filtered] =&gt; 
              [validators] =&gt; Array
                  (
                      [0] =&gt; Zend_Validate_File_Upload
                  )
  
          )
  
      [audio_file] =&gt; Array
          (
              [name] =&gt; 
              [type] =&gt; 
              [tmp_name] =&gt; 
              [error] =&gt; 4
              [size] =&gt; 
              [options] =&gt; Array
                  (
                      [ignoreNoFile] =&gt; 
                      [useByteString] =&gt; 1
                      [magicFile] =&gt; 
                      [detectInfos] =&gt; 1
                  )
  
              [validated] =&gt; 
              [received] =&gt; 
              [filtered] =&gt; 
              [validators] =&gt; Array
                  (
                      [0] =&gt; Zend_Validate_File_Upload
                  )
          )
  )
  </code></pre>
  
  <p>This is my Zend code its works only when both files are selected</p>
  
  <pre><code>if (! empty ( $post ['type'] )) {
  
      $adapter = new Zend_File_Transfer ();
  
  //  echo "&lt;pre&gt;"; print_r($_FILES);   "&lt;/pre&gt;"; exit;
  
      if ($post ['type'] == 'Image' &amp;&amp; ! empty ( $_FILES ['image_file'] ['name'] )) {
  
          $files = $adapter-&gt;getFileInfo();
  
  
          echo "&lt;pre&gt;"; print_r($files);   "&lt;/pre&gt;"; exit;
          $files = $adapter-&gt;getFileInfo();
  
          $files_path = $config-&gt;topic_images-&gt;path; 
  
          // Limit the MIME type of all given files to gif and jpeg images
  //      $adapter-&gt;addValidator ( 'MimeType', false, array ('image/jpeg', 'image/png', 'image/jpg' ) );
  
  //      $adapter-&gt;addValidator ( 'Extension', false, 'png,jpeg,jpg' );
  
  //      $adapter-&gt;addValidator ( 'FilesSize', false, array ('min' =&gt; '1kB', 'max' =&gt; '5MB' ) );
  
  //      $adapter-&gt;addValidator ( 'ImageSize', false, array ('minwidth' =&gt; 0, 'maxwidth' =&gt; 800, 'minheight' =&gt; 0, 'maxheight' =&gt; 800 ) );
  
  // Limit the size of a image to a height of 100-200 and a width of 40-80 pixel
  
  
      }elseif($post ['type'] == 'Audio' &amp;&amp; ! empty ( $_FILES ['audio_file'] ['name'] )) {
  
          $files_path = $config-&gt;topic_audio-&gt;path;
  
      }elseif($post ['type'] == 'Video' &amp;&amp; ! empty ( $post ['video_file'] )) {
  
      }
  
  
  $files = $adapter-&gt;getFileInfo ();
  
  $file_name = null;
  $tmpArr = null;
  
  $fname = null;
  $fext = null;
  
  
          foreach ( $files['image_file'] as $file =&gt; $info ) {
      if (! empty ( $info ['name'] )) {
          $fname = substr ( $info ['name'], 0, strrpos ( $info ['name'], "." ) );
          $fext = substr ( $info ['name'], strrpos ( $info ['name'], "." ) );
      }
  }
  
  
      if (! empty ( $fname )) {
  
      $file_name = $fname . "-" . $post ['topic_id'] . $fext;
  
      $horrible_chars = array ("~", "@", "#", "$", "%", "^", "&amp;", "*", "(", ")", " " );
  echo     $cleanfilename = str_replace ( $horrible_chars, "", $file_name );
  
  
      $adapter-&gt;setDestination ( $files_path );
  
  //  $adapter-&gt;addFilter ( 'Rename', array ('target' =&gt; $files_path . DS . $cleanfilename, 'overwrite' =&gt; true ) );
  
  
  
      if ($adapter-&gt;receive ()) {
  
      //  echo "xxx"; exit;
  
          $post ['filename'] = $cleanfilename;
          $result = $TopicModel-&gt;updateTopicassociation ( $post );
          $old_file = $files_path . DS . $post ['existing_file'];
  
          if (file_exists ( $old_file )) {
              if ($file_name != $post ['existing_file']) {
                  @unlink ( $old_file );
              }
          }
  
          $this-&gt;_flashMessenger-&gt;addMessage ( 'Topic '.$post['type'].'added successfully' );
      } else {
  
  
      $errors = $adapter-&gt;getErrors();
      print_r($errors); exit;
  
          $post ['filename'] = null;
          $res_delete = $TopicModel-&gt;updateTopicassociation ( $post ['topic_id'] );
          $this-&gt;_flashMessenger-&gt;addMessage ( 'Error(s) encountered. File Association not updated.' );
      }
  }
  
  //    else {
  //      if (! empty ( $post ['chkDelete'] ) &amp;&amp; $post ['chkDelete'] == 1) {
  //          $post ['filename'] = null;
  //          $result = $jobModel-&gt;updateJobLogo ( $post );
  //          $old_file = $files_path . DS . $post ['c_image_name'];
  //          
  //          if (file_exists ( $old_file )) {
  //              @unlink ( $old_file );
  //          }
  //      }
  //    }
  }
  </code></pre>
  
  <p>I've spent the whole day trying to upload only an image or audio file. Does anyone have any idea what the problem could be?</p>
  
  <p><strong>Updated with form inputs</strong>
      baseUrl(). "/" . $this->modulename; ?>/topic/action); ?>"></p>
  
  <pre><code>      &lt;input type="file" id="image_file" name="image_file"&gt;
      &lt;/form&gt;
  
     &lt;input type="text" name="video_file"  size="50" id="video_file" /&gt;
  </code></pre>