|
public void OnChangeUpload(UploadChangeEventArgs args)
{
foreach (var file in args.Files)
{
var path = Path.GetFullPath("wwwroot\\Images\\") + file.FileInfo.Name;
FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
file.Stream.WriteTo(filestream);
filestream.Close();
file.Stream.Close();
pathUrl = path;
}
} |
Hello, Thanks for your reply.
How can i view the selected image before upload if autoupload = false ?
So the user can at least see the image selected before clicking on Upload !
|
<div class="col-lg-12 control-section">
<div class="control_wrapper">
<div id="dropArea" style="height: auto; overflow: auto">
<SfUploader @ref="uploderObj" ID="UploadFiles" AllowedExtensions=".png,.jpeg,jpg">
<UploaderEvents ValueChange="onChange" OnRemove="onRemove"></UploaderEvents>
<UploaderTemplates>
<Template>
<span class="wrapper">
<img class="upload-image" alt="Image"
src="@(files.Count >0 ? files.Where(item=>item.Name == context.Name)?.FirstOrDefault()?.Path : string.Empty)">
</span>
<div class="name file-name" title="@(context.Name)">@(context.Name)</div>
<div class="file-size">@(context.Size)</div>
<span class="e-icons e-file-remove-btn remove" id="removeIcon" title="Remove"></span>
<span class="e-upload-icon e-icons e-file-remove-btn" title="Upload" id="iconUpload"></span>
</Template>
</UploaderTemplates>
</SfUploader>
</div>
</div>
</div>
<style>
.control_wrapper {
width: 350px;
margin: 0 auto;
}
</style>
<style>
.control_wrapper {
width: 350px;
margin: 0 auto;
}
</style>
@code {
private SfUploader uploderObj;
private object selectedFile { get; set; }
List<fileInfo> files = new List<fileInfo>();
public class fileInfo
{
public string Path { get; set; }
public string Name { get; set; }
public double Size { get; set; }
}
public void onChange(UploadChangeEventArgs args)
{
files = new List<fileInfo>();
foreach (var file in args.Files)
{
var path = Path.GetFullPath("wwwroot\\Images\\") + file.FileInfo.Name;
FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
file.Stream.WriteTo(filestream);
filestream.Close();
file.Stream.Close();
files.Add(new fileInfo() { Path = "/Images/" + file.FileInfo.Name , Name = file.FileInfo.Name, Size = file.FileInfo.Size });
}
}
public void onRemove(RemovingEventArgs args)
{
foreach (var removeFile in args.FilesData)
{
if (File.Exists(Path.Combine(@"wwwroot\Images", removeFile.Name)))
{
File.Delete(Path.Combine(@"wwwroot\Images\", removeFile.Name));
}
}
}
public void uploadFile(MouseEventArgs args)
{
this.uploderObj.Upload(selectedFile);
}
} |
Hi together
so far it seems to work.
How to only pick a directory ( only Directory no Files)
to store a path for Application's ( Setting's for Folders even on NetworkDrives, Path to Documents ...)
Kind Regards
Hi Sevvandhi,
thank's for reply, i need this kind of directory Picker and that would be a great enhancement
( in fact is essential 😊 , cause a lot users are not able to type correct pathinfo to the app ;-) )
like this project Fugu API Tracker
on File System Access API showDirectoryPicker() … https://web.dev/file-system-access/
thanks in advance
sir this a project path concatenate. How to get Physical path where I brows file path