Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: joindre_document.php
  2. ===================================================================
  3. --- joindre_document.php        (revisione 38606)
  4. +++ joindre_document.php        (copia locale)
  5. @@ -31,7 +31,27 @@
  6.                 return $files;
  7.        
  8.         if (_request('joindre_upload')){
  9. -               $post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES'];
  10. +    if (isset($_SERVER['HTTP_X_FILE_NAME']) && isset($_SERVER['CONTENT_LENGTH'])) {  
  11. +      if($_SERVER['CONTENT_LENGTH']>0) {
  12. +        $uploadedContent = file_get_contents("php://input");
  13. +        //detect data URI
  14. +        if (preg_match("/^data:[^;]+(;charset=\"[^\"]+\")?(;base64)?,/",$uploadedContent,$m)) {
  15. +          if($m[2]) //base64 encoded -> decode data
  16. +            $uploadedContent = base64_decode(substr($uploadedContent,strlen($m[0])));
  17. +          else //no decode, just strip headers
  18. +            $uploadedContent = substr($uploadedContent,strlen($m[0]));
  19. +        }
  20. +        file_put_contents($tmp_dir = tempnam(_DIR_TMP, 'tmp_upload'),$uploadedContent);
  21. +        $post = array(
  22. +          array("name" => $_SERVER['HTTP_X_FILE_NAME'], "tmp_name" => $tmp_dir, "error" => 0)
  23. +        );
  24. +      } else {
  25. +        spip_log("file upload error");
  26. +        $post = array(array("error" => 4));    
  27. +      }
  28. +       } else {
  29. +      $post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES'];
  30. +    }
  31.                 $files = array();
  32.                 if (is_array($post)){
  33.                         include_spip('action/ajouter_documents');
  34. @@ -297,4 +317,4 @@
  35.         return array($extension,$name);
  36.  }
  37.  }
  38. -?>
  39. \ No newline at end of file
  40. +?>