Hello
Is there a built in function to do file upload , i need 2 things 1 is to store the file name and location in the database and 2nd upload that file to a location on a different server.
if so please point me to a sample.
Regards Anwar :D
7 Answer(s)
-
0
Hi,
The only file upload sample is in the ProfileController.ChangeProfilePicture method. It is used to upload profile picture of a user. You can also see it's client side code to understand how it works. Here, we used AJAX file uploading.
-
0
I'm currently implementing Blueimp file upload into my aspnetzero example solution.
Once completed, I'll fork.
This is MVC5, but works very nice for multiple upload and gallery:
<a class="postlink" href="https://github.com/CodeHeight/jQuery-File-Upload.MVC5">https://github.com/CodeHeight/jQuery-File-Upload.MVC5</a>
-
0
Thanks @JoshYates, we appreciate it :)
-
0
I'm taking small steps with my file upload functionality in my aspnetzero project and would like your opinion/advice.
My current functionality: User can upload multiple files.
Currently developing: create guid for each file uploaded. save image attributes to database. create image grouping for gallery.
Future development: save images in Azure storage
Where do you recommend I save uploaded images within the folder structure? I want to use the private method already created:
private void SetAppFolders() { var appFolders = IocManager.Resolve<AppFolders>();
Should I save the images in:
Web.Mvc project contains the presentation/API layer (Controllers, Views, javascripts, styles, images and so on) for backend and frontend applications.
or
Web.Host project does not contain any view/css/js files. Instead, it just serves the application as remote API. So, any device can consume your application as API.
Thank you.
- Josh
-
0
Hi,
Did you considered storing them in database ? As you know, we already have an implementation for that.
See, <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/tree/5fef9a8e7b894fd9586eba9f8dc50bbd3e629b2f/src/MyCompanyName.AbpZeroTemplate.Core/Storage">https://github.com/aspnetzero/aspnet-ze ... re/Storage</a>.
If you want to store in file system, you can create a similar class to <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/blob/5fef9a8e7b894fd9586eba9f8dc50bbd3e629b2f/src/MyCompanyName.AbpZeroTemplate.Core/Storage/DbBinaryObjectManager.cs">https://github.com/aspnetzero/aspnet-ze ... Manager.cs</a>, in the future you can replace it with your azure blob storage implementation easily.
-
0
Yes, I looked at the code for saving images in the database, but I was going to go with a file system for now. I want my client to be able to upload multiple files at once and use blueimp jquery upload. I'll save the files here:
private void SetAppFolders() { var appFolders = IocManager.Resolve<AppFolders>(); appFolders.SampleProfileImagesFolder = Path.Combine(_env.WebRootPath, @"Common\Images\SampleProfilePics"); appFolders.TempPath = Path.Combine(_env.WebRootPath, @"Temp"); appFolders.TempFileDownloadFolder = Path.Combine(_env.WebRootPath, @"Temp\Downloads"); appFolders.WebLogsFolder = Path.Combine(_env.ContentRootPath, @"App_Data\Logs"); appFolders.UploadImages = Path.Combine(_env.WebRootPath, @"Common\Upload"); appFolders.Thumbs = Path.Combine(_env.WebRootPath, @"Common\Upload\Thumbs");
-
0
Hi,
It is ok then.
I suggest you to create a folder for each tenant like "Common\Uploads\1\Thumbs" or "Common\Uploads\2\Thumbs". In this way you can easily move all uploads of a single tenant easily.
But it is up to you :)