
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 1.52 KB | hits: 7 | expires: Never
Index: joindre_document.php
===================================================================
--- joindre_document.php (revisione 38606)
+++ joindre_document.php (copia locale)
@@ -31,7 +31,27 @@
return $files;
if (_request('joindre_upload')){
- $post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES'];
+ if (isset($_SERVER['HTTP_X_FILE_NAME']) && isset($_SERVER['CONTENT_LENGTH'])) {
+ if($_SERVER['CONTENT_LENGTH']>0) {
+ $uploadedContent = file_get_contents("php://input");
+ //detect data URI
+ if (preg_match("/^data:[^;]+(;charset=\"[^\"]+\")?(;base64)?,/",$uploadedContent,$m)) {
+ if($m[2]) //base64 encoded -> decode data
+ $uploadedContent = base64_decode(substr($uploadedContent,strlen($m[0])));
+ else //no decode, just strip headers
+ $uploadedContent = substr($uploadedContent,strlen($m[0]));
+ }
+ file_put_contents($tmp_dir = tempnam(_DIR_TMP, 'tmp_upload'),$uploadedContent);
+ $post = array(
+ array("name" => $_SERVER['HTTP_X_FILE_NAME'], "tmp_name" => $tmp_dir, "error" => 0)
+ );
+ } else {
+ spip_log("file upload error");
+ $post = array(array("error" => 4));
+ }
+ } else {
+ $post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES'];
+ }
$files = array();
if (is_array($post)){
include_spip('action/ajouter_documents');
@@ -297,4 +317,4 @@
return array($extension,$name);
}
}
-?>
\ No newline at end of file
+?>