使用iframe文件上传的问题

浏览:1366 发布日期:2013/08/24 分类:求助交流 关键字: 上传 iframe thinkphp
我使用iframe 里面 form 上传 但是不知道怎么将 文件地址 传给另一个方法

代码如下:class VideoAction extends CommonAction{
public $dir = '';
/*添加视频表单*/
public function addVideoHandle(){
        p($_POST);
        die;
        $data = array(
            'title' => $_POST['title'],
            'content' => $this->dir,
            'summary' => $_POST['summary'],
            'author' => $_POST['author'],
            'time' => time(),
            'click' => (int)$_POST['click'],
            'cid' => (int)$_POST['cid'],
        );
        if($bid = M('video')->add($data)){
            set_time_limit(500); 
            echo "5秒后跳转";
            $this->redirect(GROUP_NAME.'/Video/index');
        }else{
            $this->error('添加失败');
        }
    }

/*上传视频表单*/
public function upVideoHandle(){
   set_time_limit(600);  
   if($_SERVER['REQUEST_METHOD']=='POST') {  
        $dir = "./Uploads/vid/" . $_FILES["test_file"]["name"];
        if(move_uploaded_file($_FILES["test_file"]["tmp_name"], $this->dir)){ 
                echo "<p>上传成功</p>";
        }else{
                echo "<p>上传失败</p>";
                echo "10秒后跳转...";
                set_time_limit(1000); 
                $this->redirect(GROUP_NAME.'/Video/index');
        }
    }
}

/*form表单显示*/
public function button(){ 
     $id = $_GET['id'];
     $html = '<form enctype="multipart/form-data" id="upload_form" name="form1" action="'. U(GROUP_NAME.'/Video/upVideoHandle') .'" method="POST">';  
     $html .= '<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key"  value="' . $id .'"/> ';
     $html .= '<input type="file" id="test_file" name="test_file" /><br/><br/>';  
     $html .= '<input onclick="window.parent.startProgress(); return true;" type="submit" value="上传"/> </form>';
     echo $html;      
}

/*进度条*/
public function place(){
     session_start();  
     if(isset($_GET['progress_key'])) {  
          $status = apc_fetch('upload_'.$_GET['progress_key']);  
          echo ($status['current']/$status['total'])*100;  
      }  
}
}
这是模板
<iframe id="theframe" name="theframe" src="{:U(GROUP_NAME . '/Video/button')}?id={$id}" style="border: 0; height: 100px; width: 400px;" ></iframe>
就是不知道怎么将upVideoHandle里面的$dir 传给 addVideoHandle,我是先上传再点击保存后执行addVideoHandle方法写入数据库的 现在就是得不到$dir(文件地址)

还有一个为什么同一个类,$dir是成员变量 为什么upVideoHandle赋值后 addVideoHandle 显示$dir还是空值 难道不是使用同一个实例化的类吗?

各位哥哥姐姐 大神大虾 求解啊。
最佳答案
评论( 相关
后面还有条评论,点击查看>>