问题
I have created a custom uploader using Plupload's core api and it works well but one feature I would like to add is how to upload the contents of a folder when it is dragged onto the drop_element (doing this with individual files works perfectly).
The plupload object does detect the folder name but doesn't capture any of the files in the folder.
Thanks
回答1:
This isn't possible, unless the user is using chrome.
回答2:
The minimal line to ensure you are compatible with most browsers is:
<input type="file" directory="" webkitdirectory="" mozdirectory="" />
So, we know that Chrome, browsers with WebKit and Firefox are compatible with the 'directory' parameters. Then you're better to give it a style, because it will appear as "Choose files".
Most websites are using the 'fakefile' approach:
div.fileinputs
{
position: relative;
}
div.fakefile
{
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
<div class="fileinputs">
<input type="file" class="file" />
<div class="fakefile">
<input />
<img src="search.gif" />
</div>
</div>
I know the post is old, but nowadays, we often sync our folders with some cloud on the web, so the file by file method is less used.
来源:https://stackoverflow.com/questions/9618521/upload-contents-of-an-entire-folder-using-plupload