2012-12-15
jojosati
Media Manager can't upload any file when using QuickPHP, while XAMPP can.
looking into source inc/media.php
There are bug from both QuickPHP and DokuWiki
1. QuickPHP not report $SERVER["CONTENT_LENGHT"]
so the line if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) will always raise.
2. after that, It's a Doku bug - trying to unlink the closed stream $target.
-----------------------------------------------
function media_upload_xhr($ns,$auth){
if(!checkSecurityToken()) return false;
global $INPUT;
$id = $INPUT->get->str('qqfile');
list($ext,$mime,$dl) = mimetype($id);
$input = fopen("php://input", "r");
if (!($tmp = io_mktmpdir())) return false;
$path = $tmp.'/'.md5($id);
$target = fopen($path, "w");
$realSize = stream_copy_to_stream($input, $target);
fclose($target);
fclose($input);
-- if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]){
-- unlink($target);
++ if ($_SERVER["CONTENT_LENGTH"] && $realSize != (int)$_SERVER["CONTENT_LENGTH"]){
++ //unlink($target);
unlink($path);
return false;
}
$res = media_save(
array('name' => $path,
'mime' => $mime,
'ext' => $ext),
$ns.':'.$id,
(($INPUT->get->str('ow') == 'checked') ? true : false),
$auth,
'copy'
);
unlink($path);
if ($tmp) dir_delete($tmp);
if (is_array($res)) {
msg($res[0], $res[1]);
return false;
}
return $res;
}
---------------------------------------