Skip to content

Instantly share code, notes, and snippets.

@cpatrick
Created March 27, 2013 18:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpatrick/5256635 to your computer and use it in GitHub Desktop.
Save cpatrick/5256635 to your computer and use it in GitHub Desktop.
Simple test for folder uploading.
<html>
<head>
<title>HTML5 Folder Upload Test</title>
</head>
<body>
<div id="container">
<input type="file" id="file_input" name="file_input_folder[]"
multiple webkitdirectory="" mozdirectory="true" directory="" />
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var printFiles = function (event) {
var files = event.currentTarget.files;
for (var indx in files) {
var curFile = files[indx];
console.log(curFile.webkitRelativePath);
console.log(curFile.slice(0,curFile.size));
}
console.log(files);
};
$('#file_input').change(printFiles);
</script>
</body>
</html>
@cpatrick
Copy link
Author

I made this to see if recursive upload was possible without a browser plugin. It's only possible on Chrome.

@athulmurali
Copy link

Thanks. This helped me to upload recursive folders with relative path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment