Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend#u Progressbar+;JQuery+;上传视频_Php_Javascript_Jquery_Zend Framework_Progress Bar - Fatal编程技术网

Php Zend#u Progressbar+;JQuery+;上传视频

Php Zend#u Progressbar+;JQuery+;上传视频,php,javascript,jquery,zend-framework,progress-bar,Php,Javascript,Jquery,Zend Framework,Progress Bar,我想在上传视频(*.flv格式)时在我的应用程序中显示动态进度条。我在网上搜索了2个多小时,但找不到任何教程来指导我完成这个过程 到目前为止,我所拥有的: 上传视频的脚本 jQuery库包含在本节中 但下一步该怎么办呢?以下是用于上传我使用的视频的控制器操作: public function uploadPublicVideoAction() { $request = $this->getRequest(); $media = $this->_getTable('

我想在上传视频(*.flv格式)时在我的应用程序中显示动态进度条。我在网上搜索了2个多小时,但找不到任何教程来指导我完成这个过程

到目前为止,我所拥有的:

  • 上传视频的脚本
  • jQuery库包含在本节中
但下一步该怎么办呢?以下是用于上传我使用的视频的控制器操作:

public function uploadPublicVideoAction()
{
    $request = $this->getRequest();
    $media = $this->_getTable('Media');

    $form = $this->_getForm('UploadPublicVideo',
                            $this->_helper->url('upload-public-video'));
    // if POST data has been submitted
    if ($request->isPost()) {
        // if the UploadPublicVideo form has been submitted and the submitted data is valid
        if (isset($_POST['upload_public_video']) && $form->isValid($_POST)) {

            $data = $form->getValues();
            $data['user_id'] = $this->view->identity->id;

            $ext = end(explode('.', $form->video->getFileName()));

            $dbTrans = false;

            try {

                $db = $this->_getDb();
                $dbTrans = $db->beginTransaction();

                $data['type'] = 'video';
                $data['status'] = 'public';
                $paths = $media->add($data, $ext);

                if (file_exists($paths[0])) {
                   unlink($paths[0]);
                }
                if (file_exists($paths[1])) {
                   unlink($paths[1]);
                }

                // add filter for renaming the uploaded photo
                $form->video->addFilter('Rename',
                                        array('target' => $paths[0],
                                              'overwrite' => true));

                // upload the video
                $form->video->receive();

                // create a thumbnail
                //$this->_helper->FlvThumbnail($path[0], $path[1]);

                $db->commit();

                $form->reset();

                $this->view->success = 'Public video successfully uploaded';

            } catch (Exception $e) {
                if (true === $dbTrans) {
                    $db->rollBack();
                }
                $this->view->error = $e->getMessage();
            }

        }
    }

    $this->view->headTitle('Upload Public Video');
    $this->view->form = $form;
}
有谁能告诉我一个简单的方法来同时使用Zend_Progressbar和jQuery来实现动态上传Progressbar吗?

您可以使用长轮询(comet)或短轮询(ajax)来实现所需的效果。对于前者,我建议在iFrame中发出请求,并让您的代码写出JS,JS将在它们进入时执行,而后者只需执行以下操作:

var pollingId = window.setInterval(poll, 250);
function poll(){
   //make an AJAX request, do something with it (like update your progress bar).
   if(done){
      window.clearInterval(pollingId);
   }
}

你介意发布你的解决方案吗?我正在努力实现同样的目标。