title: SWFUpload image upload fails on PHP with 'Partial File Uploaded'
body: <p>Okay, so this is a tough one, I've spent hours looking for a solution/problem. I'm using SWFUpload to upload images without reloading the page (with a fancy progressbar too), this works fine when I'm on localhost (Wamp server), but it goes nuts when I try to do so on my real linux server (which is the only possible flag as far as I could see), it's running Apache2 and PHP5. As I said the front-end is fine (apart maybe from the fact it's flash).
  The back-end code is as follows:</p>
  
  <p>SWFUpload_settings.js</p>
  
  <pre><code>var swfu_settings ={upload_url  : "upload.php",
                  flash_url   : "flash/swfupload.swf",
                  button_placeholder_id   : "upload_flash",
                  file_size_limit : "2 MB",
                  file_types  : "*.gif;*.jpg;*.png",
                  file_post_name  :   "Filedata",
                  file_queue_limit    :   1,
                  post_params     :   {
                          "PHPSESSID" : getCookie()
                  },
                  upload_start_handler    : upload_start,
                  upload_error_handler    : upload_error,
                  upload_complete_handler : upload_complete,
                  upload_progress_handler : upload_progress,
                  file_queued_handler :   file_queued,
                  button_disabled : false,
                  button_width : 120, 
                  button_height : 22,
                  button_text : '&lt;div class="adm_upload"&gt;Select image&lt;/div&gt;',
                  button_text_style : '.adm_upload{color:#ff0000;}'
                  };
  </code></pre>
  
  <p>upload.php</p>
  
  <pre><code>function manageUpload(){
          if( isset($_FILES['Filedata']) ){
              $dest_dir = $_SERVER[DOCUMENT_ROOT]."/images/products";
              $destination =  $_SERVER[DOCUMENT_ROOT]."/images/products/" . $_FILES['Filedata']['name'];
              if( is_dir($dest_dir) ){
                  if( is_writable($dest_dir) ){
                      if( !move_uploaded_file($_FILES['Filedata']['tmp_name'], $destination ) ){
                          $html_body = '&lt;h1&gt;File upload error!&lt;/h1&gt;';
                          switch ($_FILES['Filedata']['error']) {
                              case 1:
                                  $html_body .= 'The file is bigger than this PHP installation allows';
                                  break;
                              case 2:
                                  $html_body .= 'The file is bigger than this form allows';
                                  break;
                              case 3:
                                  $html_body .= 'Only part of the file was uploaded';
                                  break;
                              case 4:
                                  $html_body .= 'No file was uploaded';
                                  break;
                              default:
                                  $html_body .= 'unknown errror';
                          } 
                          echo ($html_body);
                      }
                  }
                  else{
                      echo "Says it's not writable: ".$dest_dir;
                  }
              }
              else{//not a directory?
                  echo "Says it's not a directory:".$dest_dir;
              }
          }
          else{
              echo "No file POSTED.\n";
          }
      }
  </code></pre>
  
  <p>The only error that I get is from $_FILES['Filedata']['error'] = 3, 'Only part of the file was uploaded'. The destination directory does have 777 permission and you can see I made the required checks. It simply will not work, I have no idea why. Also, the files I tried uploading had no spaces in the filename, so that shouldn't fit under the issue 206 with SWFUpload.</p>
  
  <p>As far as I can tell it can be either due to the front-end SWFUpload or back-end server configuration. Please help.</p>
  
  <p>P.S. no need to mention security, this is only allowed to be used by the server admin with external access anyhow, plus there's the front-end limitation on the files he can select (images). There was no point securing it further.</p>