2015-09-06 16 views
5

Tôi có plugin này bootstrap tập tin đầu vào có thể được tìm thấy ở đây: http://plugins.krajee.com/file-basic-usage-demoLàm thế nào để loại bỏ nút tải lên trong Bootstrap file Input

Plugin này trông giống như dưới đây:

enter image description here

Bây giờ những gì tôi muốn cần làm là xóa nút tải lên này của plugin này. Có ai biết làm thế nào để làm điều này? Hay có ai đã thử? Cảm ơn nhiều.

+0

Tôi không nghĩ rằng bạn nên loại bỏ nút đó. Tệp sẽ được gửi tới máy chủ * chỉ * sau khi nhấp vào nút 'Tải lên'. Nút "Duyệt" không đủ, nó chỉ được sử dụng để chọn tệp. –

+0

Tôi chỉ muốn xóa nút tải lên đó và thêm nút gửi thay vì tôi muốn hình ảnh đó được lưu trữ trong db. – Makudex

+1

Bạn chỉ có thể thay đổi 'uploadLabel'. Xem tài liệu tại https://github.com/kartik-v/bootstrap-fileinput. –

Trả lời

11

Cuối cùng tìm thấy câu trả lời, bằng cách chỉnh sửa mã này ở đây từ fileinput.js:

$.fn.fileinput.defaults = { 
    language: 'en', 
    showCaption: true, 
    showPreview: true, 
    showRemove: true, 
    showUpload: false, // <------ just set this from true to false 
    showCancel: true, 
    showUploadedThumbs: true, 
    // many more below 
}; 
+0

lưu ý rằng trong phiên bản mới nhất, một số mặc định có thể thay đổi vì mã của bạn gây ra một ngoại lệ. tuy nhiên, sử dụng nó như thế này "$ .fn.fileinput.defaults.showUpload = false;" công trinh. Cảm ơn! –

+0

Câu trả lời từ Hanny Setiawan sẽ tồn tại nếu bạn hoặc nhà phát triển khác nâng cấp phiên bản của thư viện tải tệp bootstrap bạn đang sử dụng trong dự án của bạn, thay đổi này sẽ bị mất. –

15

Bạn chỉ có thể sử dụng các đoạn sau

$("#your-input-type-file-ID").fileinput({ 
    'showUpload': false 
}); 
+1

Đây là câu trả lời chính xác hơn sau đó được chọn, vì câu trả lời được lựa chọn đang thay đổi cài đặt thư viện trực tiếp :) –

+1

Hi @ StrahinjaDjurić cho tôi Tôi chỉ không thích các giải pháp "không phải bản địa". Vì vậy, đối với lập trình viên, tôi luôn đề xuất các giải pháp "bản địa" cho mọi thứ. Cảm ơn anh trai. –

4

Bạn có thể làm điều đó một cách đơn giản cũng chỉ đơn giản là viết trong một thuộc tính data-show-upload="false" và nó cũng sẽ hoạt động !!

0

 <!-- bootstrap 4.x is supported. You can also use the bootstrap css 3.3.x versions --> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"> 
 
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" /> 
 
    <!-- if using RTL (Right-To-Left) orientation, load the RTL CSS file after fileinput.css by uncommenting below --> 
 
    <!-- link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /--> 
 
    <!-- optionally uncomment line below if using a theme or icon set like font awesome (note that default icons used are glyphicons and `fa` theme can override it) --> 
 
    <!-- link https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css media="all" rel="stylesheet" type="text/css" /--> 
 
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
 
    <!-- piexif.min.js is only needed for restoring exif data in resized images and when you 
 
     wish to resize images before upload. This must be loaded before fileinput.min.js --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/js/plugins/piexif.min.js" type="text/javascript"></script> 
 
    <!-- sortable.min.js is only needed if you wish to sort/rearrange files in initial preview. 
 
     This must be loaded before fileinput.min.js --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/js/plugins/sortable.min.js" type="text/javascript"></script> 
 
    <!-- purify.min.js is only needed if you wish to purify HTML content in your preview for 
 
     HTML files. This must be loaded before fileinput.min.js --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/js/plugins/purify.min.js" type="text/javascript"></script> 
 
    <!-- popper.min.js below is needed if you use bootstrap 4.x. You can also use the bootstrap js 
 
     3.3.x versions without popper.min.js. --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script> 
 
    <!-- bootstrap.min.js below is needed if you wish to zoom and preview file content in a detail modal 
 
     dialog. bootstrap 4.x is supported. You can also use the bootstrap js 3.3.x versions. --> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" type="text/javascript"></script> 
 
    <!-- the main fileinput plugin file --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/js/fileinput.min.js"></script> 
 
    <!-- optionally uncomment line below for loading your theme assets for a theme like Font Awesome (`fa`) --> 
 
    <!-- script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/themes/fa/theme.min.js"></script --> 
 
    <!-- optionally if you need translation for your language then include locale file as mentioned below --> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.5/js/locales/LANG.js"></script> 
 
    
 
    
 
    
 
     <script src="http://goanyone.com/js/fileinput.js" type="text/javascript"></script> 
 

 

 

 
     <div class="file-loading"> 
 
     <input id="input-44" type="file" class="file" data-preview-file-type="text"> 
 
    </div> 
 
    <script> 
 
    $(document).on('ready', function() { 
 
     $("#input-44").fileinput({ 
 
      uploadUrl: 'file-upload-batch', 
 
      maxFilePreviewSize: 10240 
 
     }); 
 

 

 
    }); 
 
    </script> 
 
    <div id="errorBlock" class="help-block"></div>

Các vấn đề liên quan