2015-09-06 46 views
5

我有這樣的引導文件的輸入插件,它可以在這裏找到:http://plugins.krajee.com/file-basic-usage-demo如何引導文件輸入刪除上傳按鈕

這個插件看起來像如下:

enter image description here

現在我想要什麼要做的是刪除這個插件的上傳按鈕。有人知道怎麼做這個嗎?還是有人試過?非常感謝。

+0

我不認爲你應該刪除按鈕。點擊「上傳」按鈕後,該文件將被髮送到服務器* only *。瀏覽按鈕是不夠的,它只用於文件選擇。 –

+0

我只是想刪除該上傳按鈕,而不是添加提交按鈕,因爲我想要將該圖像存儲在數據庫中。 – Makudex

+1

您可以更改'uploadLabel'。請參閱https://github.com/kartik-v/bootstrap-fileinput上的文檔。 –

回答

11

終於找到了答案,通過簡單地從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

請注意,在最新版本中,某些默認值可能因爲您的代碼導致異常而更改。然而,像這樣使用它「$ .fn.fileinput.defaults.showUpload = false;」作品。謝謝! –

+0

如果您或其他開發人員升級您在項目中使用的bootstrap-fileupload庫的版本,Hanny Setiawan的答案將會存活,此更改將會丟失。 –

15

你可以用以下這些片段

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

這是更正確的答案,然後選擇,因爲選擇的答案直接更改庫設置:) –

+1

Hi @StrahinjaDjurić對我來說我只是不喜歡「非本地」的解決方案。所以對於程序員,我總是建議一切的「原生」解決方案。無論如何兄弟。 –

4

你可以做一個簡單的方法也簡單地寫在屬性data-show-upload="false",我也會工作!

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>