(#69) Upload multiple images in asp net core | One to Many relationship in ef core | Image gallery

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Asp.net core tutorial: How to upload multiple images in asp net core. Here we will upload multiple images in a folder, save details of images in the database and display these images on UI using a bootstrap carousel.
    Join this channel to get access to perks:
    / @webgentle
    GitHub Repo: github.com/web...
    Subscribe WebGentle: goo.gl/PJr1pN
    Visit Our Website: webgentle.com
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    For business inquiry contact: nitish.webgentle@gmail.com
    Follow us on
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Facebook - bit.ly/36yZuQN
    Linkedin - bit.ly/2N6Onqk
    Twitter - bit.ly/2uv04AP
    Popular free courses from WebGentle
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Jira tutorial - bit.ly/jiratuto...
    Asp.Net Core Tutorial: bit.ly/aspnetco...
    Azure DevOps tutorial - bit.ly/azuredev...
    .NET Core 3.0 fundamentals - bit.ly/dotnetcore3
    MVC5 tutorial - bit.ly/mvcbynitish
    LINQ Tutorial - bit.ly/linqbyni...
    Non generic collection in c# - bit.ly/nongener...

Комментарии • 29

  • @wongguanyan2141
    @wongguanyan2141 4 года назад +3

    Hi! I'm getting error on this
    Name = file.Filename,
    URL = await UploadImage(folder, file)
    It shows error code CS1061 and CS1503 on the (Filename) and (file) ! may I know how to fix this?

  • @mazidulislamzahid6057
    @mazidulislamzahid6057 3 года назад +2

    File is being copied but only last row inserted into database. Please provide solution.
    #region File Upload
    if (files != null)
    {
    Attachment oAttachment = new Attachment();
    string CaseNo = oCaseInfo.ID;
    string newCaseFilePath = Directory.GetCurrentDirectory() + "\\wwwroot" + "\\uploads\\" + CaseNo;
    if (!Directory.Exists(newCaseFilePath)) Directory.CreateDirectory(newCaseFilePath); //directory create
    foreach (var file in files)
    {
    if (file.Length > 0)
    {
    //Getting FileName
    var fileName = Path.GetFileName(file.FileName);
    //Assigning Unique Filename (Guid)
    var myUniqueFileName = Convert.ToString(Guid.NewGuid());
    //Getting file Extension
    var fileExtension = Path.GetExtension(fileName);
    // concatenating FileName + FileExtension
    var newFileName = String.Concat(myUniqueFileName, fileExtension);
    oAttachment.CaseID = oCaseInfo.ID;
    oAttachment.AttachmentName = fileName;
    oAttachment.ModifiedAttachmentName = myUniqueFileName + fileExtension;
    oAttachment.SetupDate = DateTime.Now;
    oAttachment.AttachmentPath = newCaseFilePath;
    // Combines two strings into a path.
    var filepath = newCaseFilePath + "\\" + newFileName;
    //var filepath = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Images")).Root + $@"\{newFileName}";
    using (FileStream fs = System.IO.File.Create(filepath))
    {
    file.CopyTo(fs);
    fs.Flush();
    }
    _db.Attachment.Add(oAttachment);
    }
    }
    }
    #endregion

  • @georgesiafa4196
    @georgesiafa4196 4 года назад +1

    Thank you so much! I have been trying to do this for ages without any success, now it works thank you!

  • @asharibkamal1
    @asharibkamal1 10 месяцев назад

    upload image file name not shown how to do this

  • @kaushikbhadani
    @kaushikbhadani 3 года назад +1

    Thank you, Nitesh! Very nice explanation.

  • @sabinaghidossi6690
    @sabinaghidossi6690 Год назад

    Great tutorial! There is just something that I don't fully understand though, why you do the methods twice? One in the controller and one in the repository? Maybe I didn't understood the function of the repository. Can you kindly explain it to me? Thank you.

  • @kamilxxx6876
    @kamilxxx6876 Год назад

    Is it neccesary to create that list in book? Can you just add images to table without it?

  • @momosiafa17
    @momosiafa17 3 года назад

    How do I delete individual pictures within the gallery? I know how to delete the whole gallery image but I want to say delete one picture within the gallery? Thank you.

  • @ganesha1627
    @ganesha1627 3 года назад

    how to use jquery ajax in asp.net core. I am able to use in asp.Net framework but not in core

  • @Mamik227
    @Mamik227 Год назад

    thank you!

  • @bl7937
    @bl7937 Год назад

    How to restrict file size and and file type?

  • @MuhammadArslan-vx3rv
    @MuhammadArslan-vx3rv 3 года назад

    Hy kindly send the link of edit and delete functionality of book details

  • @deepro__
    @deepro__ Год назад

    Thank you very much, sir.

  • @kumar_codes
    @kumar_codes 4 года назад

    Can we use eager loading...while getting the images url

  • @avijitroy5104
    @avijitroy5104 3 года назад

    Sir, Thank you so much for your great tutorial. I am new in MVC. I have a Question. After choosing the image file, I want to show the image path in file upload control.

    • @mohamedkunle528
      @mohamedkunle528 3 года назад

      if you want to see the chosen photo name you can use this jquery :
      @section Scripts {

      $(document).ready(function () {
      $('.custom-file-input').on("change", function () {
      var fileName = $(this).val().split("\\").pop();
      $(this).next('.custom-file-label').html(fileName);
      });
      });

      }

  • @StorySparkInspirations
    @StorySparkInspirations 4 года назад

    while displaying the image in carousal , I am getting NullRefrence exception

    • @WebGentle
      @WebGentle  4 года назад +1

      Kindly download the entire code from GitHub repo and match your code with it. You are missing some small things in your code.

    • @StorySparkInspirations
      @StorySparkInspirations 4 года назад

      @@WebGentle Issue shorted out but I want to display latest added image of my database in carousal.

    • @WebGentle
      @WebGentle  4 года назад

      @@StorySparkInspirations It depends on your LINQ (SQL) query. Whatever records you want to display, just fetch only those from the database and the logic of .cshtml (ie display logic) will be the same.

  • @victorcaceres3592
    @victorcaceres3592 3 года назад

    very good

  • @dattatreyakulkarni541
    @dattatreyakulkarni541 3 года назад

    I have one que please clear me , why you are assigning book parameter again in bookmodel as same , we can inherit know that class we can access know , what is the problem for inheriting please clear this ,i am going with all your dotnetcore videos

    • @WebGentle
      @WebGentle  3 года назад

      Yes, OfCourse you can inherit the class. My main focus is on dot net core mvc concepts. There are lots of things that you can use/improve in the codebase as per the need.

    • @dattatreyakulkarni541
      @dattatreyakulkarni541 3 года назад

      @@WebGentle Thank you for quick response but really I learnt much from your video thank you so much

    • @dattatreyakulkarni541
      @dattatreyakulkarni541 3 года назад

      Please upload some web api with microservices we are waiting

  • @chzakirislam1700
    @chzakirislam1700 4 года назад

    Awesome tutorial..... I am following your tutorial.... Plz keep uploading videos

  • @vinaydeveloper1369
    @vinaydeveloper1369 4 года назад

    Very very helpfull video sir ..