There is a breaking change in core 3.1 for the IForm class, above is Core 2.1. make sure you add asp-action="Create" enctype="multipart/form-data" to the Create View to populate the path. After that small change, It's working like a charm for me. Kudos to Venkat, you rock!!
@Nermin9135 жыл бұрын
Awesome video. Very informative, thank you! Just a quick comment: When you use the CopyTo() method from the IFormFile interface, you instantiate a new filestream object as the parameter, resulting in you not closing the filestream object. This will give SystemIO exceptions later on if you want to delete those images from the server. A simple fix is just to instantiate the filestream object before using the CopyTo() method, and thereafter calling the Close() method: FileStream fs = new FileStream(filePath, FileMode.Create); model.Image.CopyTo(fs); fs.Close();
@admiremhlaba11925 жыл бұрын
Thank you for the pointer, alternatively you could achieve the same by doing this using(FileStream fs = new FileStream(filePath, FileMode.Create)) { model.Image.CopyTo(fs); }
@nikhilchoubisa81344 жыл бұрын
You guys saved me. I was uploading an excel file using reference of this video and later while reading that file I got following error : "the process cannot access the file because it is being used by another process". After applying this help my code worked. Thank you guys. :)
@applemanforever5 жыл бұрын
Where the hell did this guy learn all this stuff from. Absolute Monster at ASP.NET Core
@naveenbaghel29364 жыл бұрын
That's what i am wondering from very first day....And if we come to know we can also do magic.
@danishmalak92214 жыл бұрын
From microsoft asp.net core documentations
@Abhimanyukumar-vb8bz4 жыл бұрын
we can also use "col-sm-4" class wrapping div element with class "card -m-3" to restrict 3 columns in one row instead of hardcoding the style attribute with min and max-width like this : @foreach (var Employee in Model) { var photoPath = "~/Images/" + (Employee.PhotoPath ?? "banner1.jpg"); @Employee.Name View Edit Delete }
@husam-ebish5 жыл бұрын
***To Delete the old image when uploadin a new one:*** ***Interface: IPhotoRepository.cs:*** public interface IPhotoRepository { string GetOldUserPhoto(string userId); } Entity Class: EFPhotoRepository.cs (or you can name it as you want): public class EFPhotoRepository : IPhotoRepository { private readonly AppDbContext context; public EFPhotoRepository(AppDbContext context) { this.context = context; } public string GetOldUserPhoto(string userId) { var user = context.Users.SingleOrDefault(u => u.Id == userId); var userPhotoPath = user.PhotoPath; return userPhotoPath; } } ***Inject the IPhotoRepository to the Controller, do not forget the constructor & the private fields: *** ***(in my case i injected all services I needed):*** private readonly UserManager userManager; private readonly SignInManager signInManager; private readonly RoleManager roleManager; private readonly IHostingEnvironment hostingEnvironment; private readonly IPhotoRepository photoRepository; public AccountController(UserManager userManager, SignInManager signInManager, RoleManager roleManager, IHostingEnvironment hostingEnvironment, IPhotoRepository photoRepository) { this.userManager = userManager; this.signInManager = signInManager; this.roleManager = roleManager; this.hostingEnvironment = hostingEnvironment; this.photoRepository = photoRepository; } ***Implemet your Action*** ***(in my case the Action names "EditProfile" and the ViewModel names "EditUserProfileViewModel"):*** [HttpPost] public async Task EditProfile(EditUserProfileViewModel model) { string uniqueFileName = null; if (model.Photo != null) { string usersPhotosUploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "Users Photos"); var oldPhotoName = photoRepository.GetOldUserPhoto(model.Id); string fullPath = Path.Combine(usersPhotosUploadFolder + "/" + oldPhotoName); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName; string photoPath = Path.Combine(usersPhotosUploadFolder, uniqueFileName); model.Photo.CopyTo(new FileStream(photoPath, FileMode.Create)); } var user = await userManager.FindByIdAsync(model.Id); if (user == null) { ViewBag.ErrorMessage = $"User with Id: {model.Id} cannot be found"; return View("NotFound"); } else { user.Gender = model.Gender; user.Nationality = model.Nationality; user.City = model.City; user.Country = model.Country; user.PhotoPath = uniqueFileName; var result = await userManager.UpdateAsync(user); if (result.Succeeded) { return RedirectToAction("Profile", "Account", new { id = user.Id }); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return View(model); } } *//* DONT FORGET TO ADD THE IPhotoRepository and EFPhotoRepository TO Sartup.cs *//* ***This is the code:*** services.AddScoped(); ***If the annotation is helpful, don't forget to hit "like" to keep the comment up***
@carlosinigo92254 жыл бұрын
Excellent tutorial! Jquery script wasn't working for me initially, til i double checked it thoroughly and saw i was missing a '.' before 'custom-file-label'. Thank you very much!
@marcioaugusto3924 жыл бұрын
You're awesome! As always I love watching your contents and good explanations can mae we learn so much
@MmMm-tg5mq5 жыл бұрын
very concentrated video, if other guy do this he will need five or more videos.nice and informative video thanks a lot for your efforts and accept my greetings
@alensgallery5 жыл бұрын
When I get to 13:00 i need to create a fileName and use GetFilename and include it in a variable because filename property returns the complete path including the filename and the extension. Because of the filename appending, the final image path ends up having more than just the name appended. Am I missing something?? Here is the code change string fileName = Path.GetFileName(model.Photo.FileName); uniqueFileName = Guid.NewGuid().ToString() + "_" + fileName;
@northernouthouse5 жыл бұрын
Yes, I had the exact same error and your recommended code fixed the issue. Thanks!
@AmirKMilbes4 жыл бұрын
Instead of writing inline CSS, you should have used class=row and col-md-4 as in example below. 4 + 4 + 4 = 12 -- the bootstrap 12-rows model. But, you are still my great teacher. Thank you for the videos. @foreach (var employee in Model) { var photoPath = "~/images/" + employee.PhotoPath; @employee.Name View Edit Delete }
@dannybradley93465 жыл бұрын
I am attempting to use the newest VS2019 and .net core versions. The tutorials are excellent, and I was able to make it all work until the "File upload in asp net core mvc" tutorial; it uses a now-deprecated IHostingEnvironment. At that point, VS recommends IWebHostEnvironment. I tried many things and could not get IWebHostEnvironment to work without errors: "Model bound complex types must not be abstract or value types and must have a parameterless constructor. Alternatively, give the 'hostingEnvironment' parameter a non-null default value.". How to make it work?
@hughcoleman94005 жыл бұрын
I may be using a slightly older version VS2019 and .NET core and this may be just a work around, but when I encountered that error in another tutorial I used the [obsolete] attribute above the class and it worked
@Csharp-video-tutorialsBlogspot5 жыл бұрын
Hello Danny - We used IWebHostEnvironment instead of IHostingEnvironment service in Part 16 of Razor Pages Tutorial. Hope this helps. The following page has all the videos, slides and text version in sequence. www.pragimtech.com/courses/asp-net-core-razor-pages-tutorial-for-beginners/
@shrikantnathan66265 жыл бұрын
In the details view, I am not able to get the values of the model as I am getting the error of "NullReferenceException: Object reference not set to an instance of an object." how to fix this Issue?
@martinsteegh1604 жыл бұрын
I'm having the same problem, did you find a solution? Thanks in advance!
@hetalchavan94464 жыл бұрын
Getting the same error. Any help is appreciated.
@Fetretim2 жыл бұрын
Any Solutions?
@Fetretim2 жыл бұрын
Guys my problem solved, i forget to add "this.hostingEnvironment=hostingEnvironment" (hostingEnvironment = our host environment name). When i added this, its fixed.
@mofeedboss91705 жыл бұрын
Thanks so much! I really needed that in my projects, regards!
@bashirmanafikhi5 жыл бұрын
احلى استااذ فينكات الله يجزيك الخير ♥
@rabahalmuhtaseb36125 жыл бұрын
Hello Venkat. Thank you very much for this video. I have a question if possible, the example you did works fine for images and other files like Visio (.vxd) for example. However, it's not working for text files. I couldn't find examples about this topic. However, it seems I need to read the text file line by line and save it. Just wanted to know your feedback on this issue. Thank you very much.
@opraju5 жыл бұрын
Hi Venkat I Am getting error like NullReferenceException: Object reference not set to an instance of an object. string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); were i went wrong please guide me
@hetalchavan94464 жыл бұрын
have you found any solution yet? Even I am getting the same error
@aznbuboa4 жыл бұрын
I created a separate view for upload and I could not get image to bind to the model's property. In Home controller, the photo property of EmployeeCreateViewModel always null.
@Freeliner754 жыл бұрын
Had to dig into it. You should add to your form in Create.cshtml: enctype="multipart/form-data" to make it work now.
@aznbuboa4 жыл бұрын
@@Freeliner75 Thank you!!
@MikeS-yg7bv5 жыл бұрын
Simple Amazing . Thank you so much !!!
@NachoDev3 жыл бұрын
Now with Bootstrap 5 it´s not necesary to insert the script for the file name, it does by itself
@Fetretim2 жыл бұрын
++
@vaibhavtrikolikar49024 ай бұрын
++
@SultanAlyami5 жыл бұрын
Top Professional Solutions 👍🏼
@VidyasagarMadasu5 жыл бұрын
Dear Venkat, In client machine, how to open a pdf document in a new browser window/new tab with highlighting a given word for search. The pdf document is in server. Is it required to have pdf reader installed in server. Same thing in case of excel , does it required MS-Excel to be installed in server in order to open a excel in the client machine. Please help .
@ymtan5 жыл бұрын
Dear Venkat, Regarding the following code, hostingEnvironment.WebRootPath provides us the absolute physical path of the wwwroot folder. I would like to ask how the physical path of the wwwroot folder looks like ??? string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
@Csharp-video-tutorialsBlogspot5 жыл бұрын
wwwroot folder in in the root project folder. To see the physical path of the folder, simply right click on the wwwroot folder and select "Open Folder in File Explorer" from the context menu. On my machine the following is the physical path of the wwwroot folder C:\Projects\EmployeeManagement\EmployeeManagement\wwwroot Hope this answers your question.
@ymtan5 жыл бұрын
I would like to clarify with you regarding the following code. This code will return C:\Projects\EmployeeManagement\EmployeeManagement\wwwroot\images Path.Combine(hostingEnvironment.WebRootPath, "images"); Am I correct sir ???
@Csharp-video-tutorialsBlogspot5 жыл бұрын
Yes, that's correct.
@nazibulhaque945 жыл бұрын
Hi I m binding dynamic image on img tag helper like this (). However the browset view source renders the image path but image is not showing . what i m doing mistake please help me
@zkop15 жыл бұрын
can u open the page source and click on the link. i got error that file cant be access
@zkop15 жыл бұрын
var stream = new FileStream(filePath, FileMode.Create); model.Photo.CopyTo(stream); stream.Dispose(); // remove all resources add this to your code, if works, put like on me
@nazibulhaque945 жыл бұрын
@@zkop1 yes i got the file not found error when i bind dynamic image
@nazibulhaque945 жыл бұрын
@@zkop1 when i inspect ,its showing image path successfully bind like this but its not generating version like this
@padmanabanm61154 жыл бұрын
Will this work if you store the images in root folder upon hosting on IIS?
@allahnoorqudosi74725 жыл бұрын
Hi, venkat thank you so much for this video it is so useful for me how to download an uploaded image
@SelmanErhanekici5 жыл бұрын
it was nice to watch your video keep doing @kudvenkat
@jekscustombuilds5853 жыл бұрын
Hi, is there a way to overwrite the file or image using this method? For example, I just want to replace the image to save space on the server? Thanks in advance
@sgm2510705 жыл бұрын
Hi Kudvenkat, great tutorial so far, thankyou for making it. Just letting you know, I had to change line 6 in Details.cshtml from var photoPath = "~/images/" + (Model.Employee.PhotoPath ?? "noimage.jpg"); } to var photoPath = "/images/" + (Model.Employee.PhotoPath ?? "noimage.jpg"); } // to allow the image to show in the details view.
@vityamv5 жыл бұрын
thnx man
@javaguitarist4 жыл бұрын
Genius. What made you think of that if you don't mind my asking, Steve? I assume there is different syntax because of the @model HomeDetailsViewModel in details.cshtml but don't understand why there would be. In Django that is not an issue: you can use either one.
@sgm2510704 жыл бұрын
Thanks @@javaguitarist, sorry, but I can't remember, I think I might have read it someone online when researching why it didn't work.
@АнатолийБорткевич-ю4к5 жыл бұрын
Instead of creating new class EmployeeCreateViewModel it's better to add to existing class Employee two properties: public string PhotoPath { get; set; } [NotMapped] public IFormFile Photo { get; set; } So with Photo property we work on View and we don't have this column in DB table Employee (by owing to the attribute NotMapped: you also must add namespace System.ComponentModel.DataAnnotations.Schema). By means of PhotoPath property we save file path in DB. What do you think?
@salehalbalushi98644 жыл бұрын
Yes this is the best way, specially for large models. No need to repeat the whole model just for one or two fields. Great video Venkat, You are the best. Thanks Advance.
@OnlineKillah4 жыл бұрын
Some of my images are being saved in the wrong orientation. Please help someone, how do I keep the original orientation?
@andreit.25834 жыл бұрын
Hello, have you found any solution for this issue?
@shafinhaque21795 жыл бұрын
An unhandled exception occurred while processing the request. IOException: The filename, directory name, or volume label syntax is incorrect : EmployeeManagment.Controllers.HomeController.Create(EmployeeCreateViewModel model) in HomeController.cs model.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); I am having a problem to upload file !!!! its showing error :model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
@krutelut5 жыл бұрын
I get the same error :S
@isen15 жыл бұрын
Hello and first: GREAT GREAT GREAT and Thanks. I started learning how to code this summer. Now Iam very haby doing all ur tutorials. The last days I got stuck right here at the end. Everything worked fine till I changed the browser. If I use Firefox, everthings works good. Just as I tryed to debugg with edge or IE the line with "uniqeFilePath" in the Create Actionmethod didnt work anymore. IO Exception . The generated path was now double in the string. BUT i found a solution! add ...GetFileName()... method like this: ..... uniqueFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(model.Photo.FileName); ..... Hope U ca recommend this changing. Greatings from Germany
@bntdgp4 жыл бұрын
Sir, can you please tell me why I am not getting WebRootPath in hostingEnvironment? I am using visual studio 2019.
@saiffaidi82924 жыл бұрын
use instead of
@georgehuman72534 жыл бұрын
Which one is more efficient: To store files in DB as byte array or to store them as URL in 'wwwroot' folder?
@earllibay68144 жыл бұрын
im a bit confuse , sorry and i am open to anyone could tell why, the question is , why does venkat still include the properties NAME, dept, and remove the ID instead only Photo property in the Seperate class ? what's the purpose of being inlcude in that seperate class. ? ? ? thankyou.
@AdvikaSamantaray4 жыл бұрын
Can you please answer why created new copy of employee? Can't we add file path to existing instance received.
@Sunill_Waugh5 жыл бұрын
Hi Venkat I am receiving error "Access to the path 'E:\backup\f\MyLabs\KudvenkatEmployees\EmployeeManagement\wwwroot\images' is denied", how do I resolve this? Thanks in advance
@harishds915 жыл бұрын
Even im stuck with same thing. Were you able to find a fix?
@Sunill_Waugh4 жыл бұрын
@@harishds91 No
@harishds914 жыл бұрын
@sunilwagh I fixed it. I was making the mistake of passing just the uploadsfolderpath variable .it should have file as well. Use path.combine to combine uploadsfolder and imagefile into a variable and pass that variable to filestream.i Hope it helps.
@Sunill_Waugh4 жыл бұрын
@@harishds91 let me try it out, thanks a lot
@AshProgHelp5 жыл бұрын
Thanks for this video. Is it possible to upload .pdf file using this way?
@darkogele5 жыл бұрын
any kind of file dude
@davidhainovitz28384 жыл бұрын
Great Tutorial. I was wondering why you did not choose the Async version for uploading photos Thanks David
@SaurabhKumar-om2gz3 жыл бұрын
I have one doubt .We are not passing the value for index view for photopath so it will always be null.
@codeRS955 жыл бұрын
Hello sir, I want to make Email property required on some condition only, not always. How should I proceed to achieve this?
@YogeshKumar-hm1nq4 жыл бұрын
Very nice and helpful video, You are awesome!!
@artiomandronic53835 жыл бұрын
Great Success!!!! very nice you are the best keep doing what u doing barbosa will love my test
@shrawanchoubey92245 жыл бұрын
When I publish the code and upload to the servee then image folder not shown in the publish folder. Actually i m try to upload the image using core library in web api project.
@SultanAlyami5 жыл бұрын
enctype="multipart/form-data" ؟
@joseluispinzon57944 жыл бұрын
This only works for the ASP.NET 2.2 version, right? Because it doesn't work for the 3.1 version I'm working on :(
@mainframehardtutorials84414 жыл бұрын
Nope. Its working for all versions
@TamNguyen-nf8kr4 жыл бұрын
Hello, can you suggest me a solution for editing the information I created ? I having a problem with this when I cannot create an IFormFile variable to pass to my Edit action. I hope someone will know this !
@anildebata49493 жыл бұрын
Thanks sir for your content!! Very helpful ❤
@sudiptoatutube4 жыл бұрын
Dear Venkat, you have created a FileSteam object. Shouldn't we close this stream?
@adorebeauty65393 жыл бұрын
So MVC Core performs many tasks as jquery ajax along not only just binding
@shubhasismahata47265 жыл бұрын
how you have create ddl in this form that you haven't shown it.. could you explain it
@karimmessaoud31914 жыл бұрын
Great job! Thank you!
@mrmoinn5 жыл бұрын
Why is my file selection region invisible? Everything seems to work but the actual bar is invisible for some reason
@bashirmanafikhi5 жыл бұрын
thank you.. why don't we store the picture in the database ??
@rolandsoftwareguy25155 жыл бұрын
Hi Bashir, it's normally a space consideration. It's better to store the actual images somewhere that is optimised for large files. Also, it would help when you start having different versions of the same file eg thumbnails. Hope that helps
@bashirmanafikhi5 жыл бұрын
@@rolandsoftwareguy2515 thanks Roland
@wibisonoindrawan57564 жыл бұрын
How can we upload files to SQL Server ? or convert IFormFile to Base64 ?
@tetley37373 жыл бұрын
Using .net 5, the file upload in the controller was creating an empty file (size 0), and of course the images did not display. To fix this issue, I changed the file stream / copy method to the following (which worked): string uniquePhotoFilename = null; if (model.Photo != null) { string uploadFolder = Path.Combine(_hostingEnvironment.WebRootPath, "images"); uniquePhotoFilename = $"{Guid.NewGuid()}_{model.Photo.FileName}"; //string filePath = Path.Combine(uploadFolder, uniquePhotoFilename); //model.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); using (var stream = new FileStream(Path.Combine(uploadFolder, uniquePhotoFilename), FileMode.Create)) { model.Photo.CopyTo(stream); } } Thank you kudvenkat for the very informative series! Edit: I watched a few more episodes, and a modification is made to the code that implements the using statement for the file stream in part 56.
@cheonnismail36935 жыл бұрын
Nedd to do some changes in Homecontroller.cs for file upload. need to change from uniqueFileName = Guid.NewGuid().ToString() + "_" +model.Photo.FileName; to uniqueFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(model.Photo.FileName); With this I dont hit any error. Thanks bro for a very helpful video.
@kavindurandika21404 жыл бұрын
Did you see the photo that uploaded by this?
@03ferozmohd4 жыл бұрын
Thanks bro, its working for me
@nabilbenali20444 жыл бұрын
Thank you bro it worked
@naodagere82104 жыл бұрын
Sure worked this for me
@jamilamini78075 жыл бұрын
where Can i find source code for the playlist ?
@jnaz0003 жыл бұрын
Is it possible to upload via Blob Storage on Azure?
@shahidwani64455 жыл бұрын
Thank you, please also make video on dataprotection provider in core
Thanks fir the Great Video. had to tweak a little things to get the images loaded in correct path.Initially the images wasloaded, ond ebussing found that Images was not getting copied to images folder. duirng creating path : it coming like "wwwrootimages" when ideally it should come as "wwwroot\images" So just added "\\" to path between webroot and images, and also between images and uniquefilename.
@shirajkesaribaidya8013 жыл бұрын
my images are in different size even if i am using the css class like you did can someone help, please?
@waqasriaz304 жыл бұрын
My images are not styling properly. Height varies and not set to 200px
@hetalchavan94464 жыл бұрын
same issue with me
@BigAlNavidi3 жыл бұрын
Is there any place we can actually download the solution for this?
@Csharp-video-tutorialsBlogspot3 жыл бұрын
Hello AI - Yes, you have all the instructions on the following article. Hope this helps. csharp-video-tutorials.blogspot.com/2019/11/aspnet-core-mvc-course-wrap-up.html
@coolwaterdvr5 жыл бұрын
Thank you Venkat.
@TyGuy964 жыл бұрын
The program will crash after uploading a file using the Brave web browser. I had to switch to Chrome to make it work.
@gundulf56864 жыл бұрын
THANK YOU FOR THIS COMMENT!
@rkvijayvargiya66824 жыл бұрын
I wasalso using the brave browser. I switched to Mozilla and everything worked fine. Do you know why?
@МарсельХамидуллин-ь6е4 жыл бұрын
How should I apply css? Doesnot work
@vinays12344 жыл бұрын
Please make a video on uploading image to database, and displaying it on web page.
@SyriaNabek74452 жыл бұрын
Just perfect
@СтефанИвковић5 жыл бұрын
model.Photo is always null , why?
@waqasriaz304 жыл бұрын
You must have forgot to add enctype="multipart/form-data" in form tag under create.cshtml view.
@shaiktaher61635 жыл бұрын
Photo value is null on postback, (model.Photo!=null) is always false
@catarinaribeiro80884 жыл бұрын
where the Dept came from ?
@chakotay99965 жыл бұрын
Tank you sir!
@NiazMohammad4 жыл бұрын
the dbo.Employees table doesn't show the photoPath. Anyone else having such issues?
@oibwankenobi5 жыл бұрын
Can you do the same vidéo, but with a database plz? i'm trying to save a file into database for cloud gaming save
@politicaltelegraph63395 жыл бұрын
Thank you sir..
@acggermed72714 жыл бұрын
hello friend, why not provide the sources for this video lesson?
@jcchin54975 жыл бұрын
how about download ?
@codeautomate81555 жыл бұрын
what is navigation property
@AshutoshKumar-kt1dd5 жыл бұрын
Great
@TheAbubakarbaig4 жыл бұрын
why didn't you created a partial class of employee instead of making a whole new class with photo prop?
@TheAbubakarbaig4 жыл бұрын
ok my bad, its creating field for it in the database even its in the partial class.
@lordjim99714 жыл бұрын
Great but how to download file?
@j0natan874 жыл бұрын
Couldnt get the label to replace "Choose file..." with the filename with this solution so I did this instead and it works: document.querySelector('.custom-file-input').addEventListener('change', function (e) { var fileName = document.getElementById("Photo").files[0].name; var nextSibling = e.target.nextElementSibling nextSibling.innerText = fileName })
@HDoBEAST4 жыл бұрын
Where did you put that?
@codeautomate81555 жыл бұрын
thank you
@suhagpatel41465 жыл бұрын
Hi Sir, Please Upload xamarin Videos Advanced Thank you.
@Asisvenia5 жыл бұрын
If you get null IFormFile then try to use: HttpContext.Request.Form.Files[0] it will fix your problem. I spent many hours to fix this issue. So, create a variable like this: var getImgFile = HttpContext.Request.Form.Files[0]; and instead of using model.Photo use getImgFile. My whole code: [HttpPost] public IActionResult Create(Gpu gpuData) { if (ModelState.IsValid) { var getImgFile = HttpContext.Request.Form.Files[0]; int maxId = GpuMockData.GpuCollection.Max(g => g.Id); gpuData.Id = maxId + 1; ///Check if image is null or not string uniqueImageName = null; if(getImgFile != null) { string uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "images"); uniqueImageName = Guid.NewGuid().ToString() + "_" + getImgFile.FileName; string filePath = Path.Combine(uploadsFolder, uniqueImageName); getImgFile.CopyTo(new FileStream(filePath, FileMode.Create)); } gpuData.Image = uniqueImageName; GpuMockData.GpuCollection.Add(gpuData); return RedirectToAction("Index", "Home"); } return View(); }
@favorivideo6284 жыл бұрын
nope that did not help, same issue
@Olegcowboyoleg Жыл бұрын
Зачем мы делаем ЭТО var photoPath = "~/images/" + (Model.Employee.PhotoPath ?? "noimage.jpg"); вместо того чтобы использовать ЭТО string filePath = Path.Combine(uploadsFolder, uniqueFileName); (из класса HomeController) ???????????????????????????? Why do we do that var photoPath = "~/images/" + (Model.Employee.PhotoPath ?? "noimage.jpg"); instead string filePath = Path.Combine(uploadsFolder, uniqueFileName); (from HomeController class)
@Olegcowboyoleg Жыл бұрын
But you are still the BEST teacher!!! I'll see you Bootsrap course, and CSS.
@hetalchavan94464 жыл бұрын
In my case, all the 3 employees are not in one row. Only 2 of them are there per row.
@arnoldjohn86204 жыл бұрын
If anyone using .core 3.1 then u probably see a green squidly in Ihostingenvironment Then use IWebHostEnvironment
@ajwagroindustry74543 жыл бұрын
Sr Please Update Your Coursee
@ivanb86624 жыл бұрын
Now need to use IWebHostEnvironment instead IHostingEnvironment
@papypypa4855 жыл бұрын
I think im in love with Sara ...
@amitlimbu50255 жыл бұрын
Now use IWebHostEnvironmen
@mainframehardtutorials84414 жыл бұрын
Yes because IHosting Environment should be removed so its better to use IWebHostEnvironment
@amitkumar-fi2tb4 жыл бұрын
Now i am feeling bore because your tutorial no longer effective...
@NiazMohammad4 жыл бұрын
Because you are lazy to search for the updated code and learn.