jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何将autoUpload选项设置为Jquery File Upload大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将autoUpload标志设置为 jQuery File Upload.
所以我尝试用这种方式编辑jquery.fileupload.js:
(function (factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        // Register as an anonymous AMD module:
        define([
            'jquery','jquery.ui.widget'
        ],factory);
    } else {
        // Browser globals:
        factory(window.jQuery);
    }
}(function ($) {
    'use strict';

    // The FileReader API is not actually used,but works as feature detection,// as e.g. Safari supports XHR file uploads via the FormData API,// but not non-multipart XHR file uploads:
    $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
    $.support.xhrFormDataFileUpload = !!window.FormData;

    // The fileupload widget listens for change events on file input fields defined
    // via fileInput setting and paste or drop events of the given dropZone.
    // In addition to the default jQuery Widget methods,the fileupload widget
    // exposes the "add" and "send" methods,to add or directly send files using
    // the fileupload API.
    // By default,files added via file input selection,paste,drag & drop or
    // "add" method are uploaded immediately,but it is possible to override
    // the "add" callback option to queue file uploads.
    $.widget('blueimp.fileupload',{

        options: {
            // The namespace used for event handler binding on the dropZone and
            // fileInput collections.           
            // If not set,the name of the widget ("fileupload") is used.
            namespace: undefined,autoUpload:true,.
            .
            .

和main.js这样:

$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload();

    // Enable iframe cross-domain access via redirect option:
    $('#fileupload').fileupload(
        'option','redirect',window.location.href.replace(
            /\/[^\/]*$/,'/cors/result.html?%s'
        )
    );

    if (window.location.hostname === 'blueimp.github.com') {
        // Demo settings:
        $('#fileupload').fileupload('option',{
            url: '//jquery-file-upload.appspot.com/',maxFileSize: 5000000,.
            .
            .

我可以看透这个

<td class="start">{% if (!o.options.autoUpload) { %}
    <button class="btn btn-primary">
        <i class="icon-upload icon-white"></i>
        <span>{%=locale.fileupload.start%}</span>
    </button>
{% } %}</td>

出现启动按钮,所以o.options.autoUpload为false,但我将其设置为true.
我能做什么?以哪种方式我可以设置autoupload直接上传图像?
谢谢!!!!

解决方法

解决了从插件网站下载的原始示例,我更改标志autoUpload:true,它的工作原理:)

大佬总结

以上是大佬教程为你收集整理的如何将autoUpload选项设置为Jquery File Upload全部内容,希望文章能够帮你解决如何将autoUpload选项设置为Jquery File Upload所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: