2014-12-26 124 views

回答

-1

您可以編輯dropzone.js文件 和行之後540:_this.hiddenFileInput.setAttribute("type", "file"); 插入代碼:_this.hiddenFileInput.setAttribute("accept", "image/*");

+1

我不認爲黑客攻擊的源代碼lib是一個好習慣 –

6

由於事實上,爲了顯示圖庫應用到Android用戶,您<input>元素必須有兩個性質明確定義:

類型其是file接受其可以是,如所提到的,image/*(或任何圖像相關的MIME類型)

一個實現這一目標的方法是通過實例化懸浮窗反對你自己,而不是依賴於懸浮窗類<form>的:

// removes the magical auto discovery of dropzone forms 
 
Dropzone.autoDiscover=false; 
 

 
// add accepted mimeTypes options (comma separated string) 
 
// myDz is the camelCased version of the id of the element that will be "dropzoned" 
 
Dropzone.options.myDz = { acceptedFiles: 'image/*'}; 
 

 
$(function(){ 
 
    // instantiate dropzone on element with #my-dz id 
 
    // if no action in the form or applying dropzone on a non form (ie a div), 
 
    // you should at least pass the url in an object as the second parameter 
 
    dz = new Dropzone('#my-dz' /*, {url:"/my-upload-url"}*/); 
 
});
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/dropzone.js"></script> 
 
    <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/dropzone.css" rel="stylesheet"/> 
 
    </head> 
 
    <body> 
 
    <div class="ctn"> 
 
     <h1>Test Dropzone Android</h1> 
 
     <form action="#" method="post" class="dropzone" id="my-dz"></form> 
 
    </div> 
 
    </body> 
 
</html>

你可以找到一些有用的(雖然有點過時)信息在這裏:Uploading photos from mobile web app

PS:感謝John誰幫我收集這些信息

0

我已經與plupload同樣的問題,我固定:

document.querySelectorAll('input[type=file]')[0].setAttribute("accept","image/*");