Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit ef155e5

Browse files
Merge pull request #14 from Ellested/folderUpload
Added folder upload feature, supported by Chrome, Edge, FireFox
2 parents 748ef9c + 98b2716 commit ef155e5

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

BlazorInputFile/FileListEntryImpl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class FileListEntryImpl : IFileListEntry
2323

2424
public string Type { get; set; }
2525

26+
public string RelativePath { get; set; }
27+
2628
public Stream Data
2729
{
2830
get

BlazorInputFile/IFileListEntry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public interface IFileListEntry
1313

1414
string Type { get; }
1515

16+
public string RelativePath { get; set; }
17+
1618
Stream Data { get; }
1719

1820
event EventHandler OnDataRead;

BlazorInputFile/wwwroot/inputfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
lastModified: new Date(file.lastModified).toISOString(),
1313
name: file.name,
1414
size: file.size,
15-
type: file.type
15+
type: file.type,
16+
relativePath: file.webkitRelativePath
1617
};
1718
elem._blazorFilesById[result.id] = result;
1819

samples/Sample.Core/Pages/MultiFile.razor

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
<p>A multi-file picker that displays information about selection and shows progress as each one is loaded.</p>
66

7-
<InputFile multiple OnChange="HandleSelection" />
7+
<label for="uploadFiles">Select File(s)</label>
8+
<InputFile id="uploadFiles" multiple OnChange="HandleSelection" />
9+
10+
<label for="uploadFolder">Select Folder</label>
11+
<InputFile id="uploadFolder" multiple webkitdirectory OnChange="HandleSelection" />
812

913
@if (selectedFiles != null)
1014
{
@@ -19,6 +23,7 @@
1923
Size: <strong>@file.Size bytes</strong>;
2024
Last modified: <strong>@file.LastModified.ToShortDateString()</strong>;
2125
Type: <strong>@file.Type</strong>
26+
Relative Path: <strong>@file.RelativePath</strong>
2227
</div>
2328

2429
<!-- Upload button -->

0 commit comments

Comments
 (0)