protected function ajaxExecute(MUser $me, MShop $shop) { $img = MRequest::file('img'); $tmpName = $img['tmp_name']; $md5 = md5_file($tmpName); $imgPath = MShopImageService::getImagePath($md5, true); if (!move_uploaded_file($tmpName, $imgPath)) { return MJsonRespond::respondFail(); } $imgType = $img['type']; $imgUrl = MShopImageService::getImageUrl($md5); $response = array('md5' => $md5, 'imgType' => $imgType, 'imgUrl' => $imgUrl); return MJsonRespond::respondSuccess('上传成功', $response); }
protected function signinExecute(MUser $me) { $img = MRequest::file('img'); $context = MRequest::request('context'); $tmpName = $img['tmp_name']; $md5 = md5_file($tmpName); $imgPath = MShopImageService::getImagePath($md5, true); if (!move_uploaded_file($tmpName, $imgPath)) { echo '<script>try{ window.parent.uploadImageFail(-1, "upload fail", "' . $context . '");}catch(e){}</script>'; return; } $imgType = $img['type']; $imgUrl = MShopImageService::getImageUrl($md5); echo '<script>try{ window.parent.uploadImageSuccess("' . $md5 . '","' . $imgType . '", "' . $imgUrl . '", "' . $context . '");}catch(e){}</script>'; }