Changeset 38547 in spip-zone for _plugins_/ddUpload/action


Ignore:
Timestamp:
Jun 2, 2010, 6:42:24 PM (10 years ago)
Author:
renato@…
Message:

upload marche pour ff et chrome pour raw et data uri donnees

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/ddUpload/action/joindre.php

    r38537 r38547  
    2121        global $redirect;
    2222        $securiser_action = charger_fonction('securiser_action', 'inc');
    23         $arg = $securiser_action();
     23  $arg = $securiser_action();
    2424
    2525        if (!preg_match(',^(-?\d+)\D(\d+)\D(\w+)/(\w+)$,',$arg,$r)) {
     
    6262    if($_SERVER['CONTENT_LENGTH']>0) {
    6363      $uploadedContent = file_get_contents("php://input");
    64       file_put_contents(
    65         $tmp_dir = tempnam(_DIR_TMP, 'tmp_upload'),
    66         base64_decode(substr($uploadedContent,strpos($uploadedContent,",")))
    67       );
     64      //detect data URI
     65      if (preg_match("/^data:[^;]+(;charset=\"[^\"]+\")?(;base64)?,/",$uploadedContent,$m)) {
     66        if($m[2]) //base64 encoded -> decode data
     67          $uploadedContent = base64_decode(substr($uploadedContent,strlen($m[0])));
     68        else //no decode, just strip headers
     69          $uploadedContent = substr($uploadedContent,strlen($m[0]));
     70      }
     71      file_put_contents($tmp_dir = tempnam(_DIR_TMP, 'tmp_upload'),$uploadedContent);
    6872      $path = array(
    6973        array("name" => $_SERVER['HTTP_X_FILE_NAME'], "tmp_name" => $tmp_dir, "error" => 0)
    7074      );
    7175    } else {
     76      spip_log("file upload error");
    7277      $path = array(array("error" => 4));   
    7378    }
Note: See TracChangeset for help on using the changeset viewer.