📄 upfilecontroller.php
字号:
<?php
class UpfileController extends Easy_Controller_Action{
public function Init(){
$this->_View->item = $this->_Request->getParams('item');
}
public function IndexAction(){
exit($this->_View->render('upfile'));
}
public function AddAction(){
$IO = new Easy_Filesystem();
if (!($this->filename = $IO->setFile($_FILES['file'], null, 'movie'))){
$this->msgbox($IO->error, false);
}else{
$item = $this->_View->item;
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="'.$this->config['basedir'].'js/jquery.js"></script>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 4px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
</head>
<body>
<script>
function remove(filename){
$.get("'.INSTALLDIR.'?mod=upfile&action=del&filename="+filename);
parent.document.getElementById("'.$item.'").value = "upload/nophoto.gif";
history.back();
}
parent.document.getElementById("'.$item.'").value = "'.$this->filename.'";
</script>
<div style="float:left;font-size:12px;"><a href="javascript:remove(\''.base64_encode($this->filename).'\')">重新上传</a></div>
</body></html>';
}
exit;
}
public function msgbox($message, $succeed=true){
$item = $this->_View->item;
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<script>
parent.document.getElementById("'.$item.'").value = "'.$this->filename.'";
location.href="'.$this->_View->installdir.'?mod=upfile&action=index&item='.$this->_View->item.'";
</script></body></html>';
}
public function delAction(){
$filename = base64_decode($this->_Request->getParam('filename'));
$IO = new Easy_Filesystem();
if (is_file(ROOT.$filename)){
$IO->delete(ROOT.$filename);
exit('true');
}else{
exit(ROOT.$filename);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -