function handle()
 {
     if (isset($_GET['behav'])) {
         if ($_GET['behav'] == 'uploadimg') {
             $name = uniqid() . '.jpg';
             move_uploaded_file($_FILES["pic"]["tmp_name"], './jae/' . $name);
             upoadTmpFile('./jae/' . $name);
             $tmp = array();
             $tmp['url'] = getTmpFileUrl($name);
             $tmp['id'] = $name;
             echo json_encode($tmp);
             exit;
         }
     }
     $smarty = new Smarty();
     $smarty->assign('logined', isLogined());
     $smarty->display('libs/view/head.ctp');
     if (isset($_POST['bookname'])) {
         $name = explode('.', $_FILES["file"]["name"]);
         $name = $name[count($name) - 1];
         if ($name == 'mobi') {
             $id = $this->doUpload();
             header("location:index.php?action=detail&bid={$id}");
             //$smarty->assign('type','success');
             //$smarty->assign('message','上传成功');
         } else {
             $smarty->assign('type', 'error');
             $smarty->assign('message', '上传失败,文件类型错误');
         }
         //$smarty->display('libs/view/alert.ctp');
     }
     $smarty->display('libs/view/upload.ctp');
     $smarty->display('libs/view/tail.ctp');
 }
Exemple #2
0
function downloadImg($url)
{
    $id = uniqid() . '.jpg';
    $data = getHtml($url);
    $local = fopen('./jae/' . $id, 'wb');
    fwrite($local, $data);
    upoadTmpFile('./jae/' . $id);
    return $id;
}