Commit cfd09b29 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'prakhar/purr-data-open_files' into emscripten

parents c43d3b38 a87c8361
Pipeline #3684 canceled with stage
......@@ -8,7 +8,7 @@
<label>
<li id="file-open">
</li>
<input id="uploadPatch" type="file" onchange="pdbundle.pdgui.upload_patch(this.files)" multiple>
<input id="uploadPatch" type="file" accept=".pd" onchange="pdbundle.pdgui.upload_patch(this.files)" multiple>
</label>
<!-- Recent Files submenu -->
......
......@@ -2035,6 +2035,25 @@ function upload_patch(files) {
return;
}
var fileInput = document.getElementById("uploadPatch");
var allowedExtension = ".pd";
// Check that the file extension is supported.
// If not, clear the input.
var hasInvalidFiles = false;
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.name.endsWith(allowedExtension)) {
hasInvalidFiles = true;
}
}
if(hasInvalidFiles) {
fileInput.value = "";
alert("Unsupported file selected.");
}
for (const file of files){
var reader = new FileReader();
reader.onload = function () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment