jQuery文件上载不显示预览

Ari*_*Ari 7 javascript jquery file-upload coffeescript

jQuery的文件上传插件不显示当前选中的文件.有谁知道我如何解决这个问题?

我已经实现了'自定义'模板(见下文); 注意我不需要显示以前上传的材料,因此没有下载模板.

我已经检查(通过日志记录)add正在调用回调并且正在调用uploadTemplate函数并返回预期值 - 由于某种原因,这些值根本没有附加到表示表.

$('#fileupload').fileupload(
  acceptFileTypes: /(\.|\/)(gif)$/i
  uploadTemplateId: null
  downloadTemplateId: null
  uploadTemplate: (obj) ->
    rows = $()
    $.each(obj.files, (idx, file) ->
      temp = "<tr class='template-upload fade'><td class='preview'><span class='fade'></span></td><td class='name'></td>'<td class='size'></td>"
      if (file.error)
        temp += "<td class='error' colspan='2'></td>"
      else
        temp += "<td><div class='progress'><div class='bar' style='width:0%;'></div></div></td><td class='start'><button>Start</button></td>"
      temp += "<td class='cancel'><button>Cancel</button></td></tr>"
      row = $(temp)
      row.find('.name').text(file.name)
      row.find('.size').text(obj.formatFileSize(file.size))
      rows = rows.add(row)
      )
    return rows
  downloadTemplate: ->
    return $()
)
Run Code Online (Sandbox Code Playgroud)

更新10/16/2012 我在fileupload的初始化中添加了以下内容:

  process: [{action: 'load', fileTypes: /^image\/(gif|jpeg|png)$/, maxFileSize: 2000000}, {action: 'resize', maxWidth: 1920, maxHeight: 1200, minWidth: 800, minHeight: 600}, {action: 'save'}]
Run Code Online (Sandbox Code Playgroud)

哪个会启动加载图像的尝试,但不幸的是,尝试会导致以下错误.有谁知道原因是什么和/或如何解决?

Uncaught TypeError: undefined (loadImage) is not a function jquery.fileupload-fp.js:87

Ari*_*Ari 8

问题是依赖项的加载顺序; 需要在其他核心依赖项之前加载Load Image.


Moe*_*oes 6

以正确的顺序加载依赖项解决了我的问题

  • 负载图像/负载image.js
  • 负载图像/负载图像ios.js
  • 负载图像/负载图像orientation.js
  • 负载图像/负载图像meta.js
  • 负载图像/负载图像exif.js
  • 负载图像/负载图像的EXIF-map.js

    (或使用缩小版)

  • jquery.iframe-transport.js

  • jquery.fileupload.js
  • jquery.fileupload-process.js
  • jquery.fileupload-image.js
  • jquery.fileupload-audio.js
  • jquery.fileupload-的Video.js
  • jquery.fileupload-validate.js
  • jquery.fileupload-ui.js tmpl.js
  • 帆布到blob.js