【问题标题】:How to do "something" after uploading file with jQuery-File-Upload使用 jQuery-File-Upload 上传文件后如何做“某事”
【发布时间】:2013-12-06 08:41:23
【问题描述】:

我正在使用此代码:(https://github.com/blueimp/jQuery-File-Upload)

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

$option = array(
    'upload_dir' => 'myurl',
    'SesId' => 1
);

$upload_handler = new UploadHandler($option);

脚本运行正常,但我想在文件上传后做一些事情:

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

$option = array(
    'upload_dir' => 'myurl',
    'SesId' => 1
);

class CustomUploadHandler extends UploadHandler {
    protected function handle_form_data($file, $index) {
        $file->SesId = $this->options['SesId'];     
    }

    protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index=null, $content_range=null) {
        $file = parent::handle_file_upload(
            $uploaded_file, $name, $size, $type, $error, $index, $content_range
        );

        if (empty($file->error)) {
        die();      
        }
        return $file;
    }
}

$upload_handler = new UploadHandler($option);

文件上传正常,但 NEVER die() ???

我错过了什么?

【问题讨论】:

  • 抱歉,上传后
  • 我不明白你的问题。上传后有“done”、“fail”、“always”事件以便做某事。但它是客户端。
  • 通过 PHP 上传文件,但答案是使用 JQuery。最后的问题是我调用了错误的实例。

标签: jquery jquery-file-upload


【解决方案1】:

问题是:我调用了错误的实例。

最后一行应该是:

$upload_handler = new CustomUploadHandler($option);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 2018-06-01
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多