Skip to content

Commit

Permalink
Added fbr@2.0.3 Now you can limit File-Types as well.
Browse files Browse the repository at this point in the history
fileSelector.accept = ‘*.png, *.jpeg, *.mp4’;
  • Loading branch information
muaz-khan committed Oct 19, 2016
1 parent f728167 commit 9f9aa66
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion FileBufferReader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-10-18 2:34:23 PM UTC
// Last time updated: 2016-10-19 12:23:04 PM UTC

// ________________
// FileBufferReader
Expand Down Expand Up @@ -328,6 +328,8 @@
selectFile(callback, true);
};

selector.accept = '*.*';

function selectFile(callback, multiple) {
var file = document.createElement('input');
file.type = 'file';
Expand All @@ -336,6 +338,8 @@
file.multiple = true;
}

file.accept = selector.accept;

file.onchange = function() {
if (multiple) {
if (!file.files.length) {
Expand Down
4 changes: 2 additions & 2 deletions FileBufferReader.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ You can use `input[type=file].onchange` instead, which is **strongly recommended
```javascript
var fileSelector = new FileSelector();

// *.png, *.jpeg, *.mp4, etc.
fileSelector.accept = '*.*';

var btnSelectFile = document.getElementById('select-file');
btnSelectFile.onclick = function() {
fileSelector.selectSingleFile(function(file) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fbr",
"preferGlobal": true,
"version": "2.0.2",
"version": "2.0.3",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down
5 changes: 5 additions & 0 deletions demo/PeerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ window.addEventListener('load', function() {
// using FileBufferReader.js

var fileSelector = new FileSelector();

// you can force specific files e.g.
// image/png, image/*, image/jpeg, video/webm, audio/ogg etc.
fileSelector.accept = '*.*';

var fileBufferReader = new FileBufferReader();

fileBufferReader.onBegin = FileHelper.onBegin;
Expand Down
4 changes: 4 additions & 0 deletions dev/FileSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function FileSelector() {
selectFile(callback, true);
};

selector.accept = '*.*';

function selectFile(callback, multiple) {
var file = document.createElement('input');
file.type = 'file';
Expand All @@ -14,6 +16,8 @@ function FileSelector() {
file.multiple = true;
}

file.accept = selector.accept;

file.onchange = function() {
if (multiple) {
if (!file.files.length) {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
document.createElement('footer');
</script>

<script src="FileBufferReader.js"></script>
<script src="https://cdn.webrtc-experiment.com/FileBufferReader.js"></script>
<script src="demo/PeerConnection.js"> </script>
<script src="demo/PeerUI.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fbr",
"preferGlobal": true,
"version": "2.0.2",
"version": "2.0.3",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down

0 comments on commit 9f9aa66

Please sign in to comment.