使用jquery upload file在CakePHP中自动上载文件

使用jquery upload file在CakePHP中自动上载文件,jquery,file,cakephp,upload,Jquery,File,Cakephp,Upload,我已将以下代码集成到CakePHP(1.3版)中: 这是工作正常,我能够成功地上传文件到服务器后,点击上传按钮。但是,我希望文件被自动上传,只要我选择他们 我将autoUpload:true选项添加到jquery.fileupload.js,并将add函数更改为: add: function (e, data) { if (data.autoUpload || (data.autoUpload !== false &&

我已将以下代码集成到CakePHP(1.3版)中:

这是工作正常,我能够成功地上传文件到服务器后,点击上传按钮。但是,我希望文件被自动上传,只要我选择他们

我将autoUpload:true选项添加到jquery.fileupload.js,并将add函数更改为:

add: function (e, data) {
                if (data.autoUpload || (data.autoUpload !== false &&
                        $(this).fileupload('option', 'autoUpload'))) {
                    data.process().done(function () {
                        data.submit();
                    });
                }
            },
无论如何,我仍然必须单击上载按钮才能将文件转到服务器。你知道如何启用自动上传吗


谢谢大家!

要在选择文件时启用自动上载,请将
autoUpload
选项设置为true

您可以在初始化$(document).ready(function(){)中的函数时使用此选项

您可以看到js文件
app\webroot\jupload\js\jquery.fileupload ui.js
。第一个选项设置为false。将其设置为true

请参阅以下代码:

(function ($) {
'use strict';

// The UI version extends the basic fileupload widget and adds
// a complete user interface based on the given upload/download
// templates.
$.widget('blueimpUI.fileupload', $.blueimp.fileupload, {

    options: {
        // By default, files added to the widget are uploaded as soon
        // as the user clicks on the start buttons. To enable automatic
        // uploads, set the following option to true:
        autoUpload: true, //<----- HERE IS WHAT YOU NEED TO CHANGE
        ..................
        ..................
(函数($){
"严格使用",;
//UI版本扩展了基本的fileupload小部件并添加了
//基于给定上传/下载的完整用户界面
//模板。
$.widget('blueimpUI.fileupload',$.blueimp.fileupload{
选项:{
//默认情况下,添加到小部件的文件会尽快上载
//当用户单击开始按钮时。要启用自动
//上载时,将以下选项设置为true:

自动上载:true,//要在选择文件时启用自动上载,请将
自动上载
选项设置为true

您可以在初始化$(document).ready(function(){)中的函数时使用此选项

您可以看到js文件
app\webroot\jupload\js\jquery.fileupload ui.js
。第一个选项设置为false。将其设置为true

请参阅以下代码:

(function ($) {
'use strict';

// The UI version extends the basic fileupload widget and adds
// a complete user interface based on the given upload/download
// templates.
$.widget('blueimpUI.fileupload', $.blueimp.fileupload, {

    options: {
        // By default, files added to the widget are uploaded as soon
        // as the user clicks on the start buttons. To enable automatic
        // uploads, set the following option to true:
        autoUpload: true, //<----- HERE IS WHAT YOU NEED TO CHANGE
        ..................
        ..................
(函数($){
"严格使用",;
//UI版本扩展了基本的fileupload小部件并添加了
//基于给定上传/下载的完整用户界面
//模板。
$.widget('blueimpUI.fileupload',$.blueimp.fileupload{
选项:{
//默认情况下,添加到小部件的文件会尽快上载
//当用户单击开始按钮时。要启用自动
//上载时,将以下选项设置为true:

autoUpload:true,//谢谢!jquery.fileupload-ui.js中的修复确实有帮助。谢谢!jquery.fileupload-ui.js中的修复确实有帮助。