From 873cd06e1bda38e0decce16d6ec7d3bdaece612e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 14:22:19 +0300 Subject: issue #50 styling the new uploader --- lib/exe/ajax.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index aa07fe7b0..52131d864 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -256,16 +256,25 @@ function ajax_mediaupload(){ if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); - if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); - if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); - if ($res) $result = array('success'=>true); + + if ($_FILES['qqfile']['tmp_name']) { + $res = media_upload($NS, $AUTH, $_FILES['qqfile']); + $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); + } + if (isset($_GET['qqfile'])) { + $res = media_upload_xhr($NS, $AUTH); + $id = $_GET['qqfile']; + } + + if ($res) $result = array('success' => true, + 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&')); if (!$result) { $error = ''; if (isset($MSG)) { foreach($MSG as $msg) $error .= $msg['msg']; } - $result = array('error'=> $msg['msg']); + $result = array('error' => $msg['msg']); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3