2017-03-26 30 views
0

我試圖實現JQuery文件上傳(http://blueimp.github.io/jQuery-File-Upload/basic.html)。當選擇文件時JQuery文件上傳不執行任何操作

問題是,當我選擇一個文件時它不反應。

有幾個問題可以幫助:

  1. 有鍍鉻控制檯沒有錯誤。
  2. 選擇一個文件不會發送到任何位置。

你知道哪裏可能是問題嗎?

選擇文件後沒有任何操作。

這是HTML:

<span class="btn btn-success fileinput-button"> 
    <i class="glyphicon glyphicon-plus"></i> 
    <span>Select files...</span> 
    <!-- The file input field used as target for the file upload widget --> 
    <input id="fileupload" type="file" name="files[]" multiple=""> 
</span> 
<br> 
<br> 
<!-- The global progress bar --> 
<div id="progress" class="progress"> 
    <div class="progress-bar progress-bar-success"></div> 
</div> 
<!-- The container for the uploaded files --> 
<div id="files" class="files"></div> 

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script> 

這是在底部(結束標記之前):

<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script> 
    <script src="/static/js/cookies.js"></script> 
    <script src="/static/theme/assets/js/bootstrap.min.js"></script> 
    <!-- Metis Menu Js --> 
    <script src="/static/theme/assets/js/jquery.metisMenu.js"></script> 
    <!-- Custom Js --> 
    <!-- Morris Chart Js --> 
    <script src="/static/theme/assets/js/morris/raphael-2.1.0.min.js"></script> 
    <script src="/static/theme/assets/js/morris/morris.js"></script> 
    <script src="/static/theme/assets/js/custom-scripts.js"></script> 


    <script src="/static/theme/assets/js/easypiechart.js"></script> 
    <script src="/static/theme/assets/js/easypiechart-data.js"></script> 

    <script src="/static/theme/assets/js/Lightweight-Chart/jquery.chart.js"></script> 

    <script src="/static/dashboardapp/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script> 
    <script src="/static/dashboardapp/jQuery-File-Upload/js/jquery.iframe-transport.js"></script> 

    <script src="/static/dashboardapp/jQuery-File-Upload/js/jquery.fileupload.js"></script> 
    <script src="/static/dashboardapp/jQuery-File-Upload/js/jquery.fileupload-ui.js"></script> 
    <script> 

     /*jslint unparam: true */ 
     /*global window, $ */ 
     $(function() { 
      'use strict'; 
      // Change this to the location of your server-side upload handler: 
      var url = "/products/products-import/"; 
      $('#fileupload').fileupload({ 
       url: url, 
       dataType: 'json', 
       done: function (e, data) { 
        $.each(data.result.files, function (index, file) { 
         $('<p/>').text(file.name).appendTo('#files'); 
        }); 
       }, 
       progressall: function (e, data) { 
        var progress = parseInt(data.loaded/data.total * 100, 10); 
        $('#progress .progress-bar').css(
         'width', 
         progress + '%' 
        ); 
       } 
      }).prop('disabled', !$.support.fileInput) 
       .parent().addClass($.support.fileInput ? undefined : 'disabled'); 
     }); 

    </script> 
+0

您可能會收到一個服務器錯誤,如最大尺寸超過 –

+0

沒辦法,沒有請求發送到服務器。它看起來不知道我選擇了該文件。 –

回答

0

你試過將腳本包裝在$(document).ready(function(){<your_code>});? 用於在文檔加載完成後運行的代碼。

+0

是的,我嘗試過。我沒有幫助。 –

相關問題