Drag & Drop or Browse - File upload Feature using HTML CSS & JavaScript

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

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

  • @CodingNepal
    @CodingNepal  3 года назад +33

    I have tried to explain each JavaScript line with comments... Hope you understand!!

  • @TheTurtleMan377
    @TheTurtleMan377 2 года назад +1

    coding nepal i love your all videos really i appericate of all over tutorial course , i understood from this channel programming

    • @CodingNepal
      @CodingNepal  2 года назад

      Glad to hear that and keep it up

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

    Merci beaucoup pour vos efforts monsieur, c'est très apprécié par les gens qui commencent la longue route.

  • @jackwalker2947
    @jackwalker2947 3 года назад +8

    The man who actually know the real use of javascript 😍😍🔥🔥
    I made projects by watching your channel and the other one is @Florin Pop channel.

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

      Thank you so much for appreciating my work 😁💙

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

      same here

  • @anitagoyal8211
    @anitagoyal8211 3 года назад +5

    Creative level 💯
    Mind blowing ❤️

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

    Thanks for all,It is easy to understand

  • @4ia08_galuhachmadfauzan3
    @4ia08_galuhachmadfauzan3 2 года назад +1

    can you change the file type to excel and if you can can you tell me how?

  • @mukeshlekhrajani3454
    @mukeshlekhrajani3454 2 года назад

    Awesome !!
    Keep up the good work...

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

    Excellent, thanks for what you are doing !!!
    Let the next video be about “Parallax effect pure JavaScript”.

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

      Noted

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

      @@CodingNepal Hello. When my task is to download only pictures, everything is ok, but as soon as I want to download mp4 videos, that's the problem. Here's what I added as you did:
      let validExtensions = ["image/jpeg", "image/jpg", "image/png", "video/mp4"];
      let videoTag = ``;
      dragArea.innerHTML = videoTag;
      Or this entire part:
      function showFile() {
      let fileType = file.type; //getting selected file type
      let validExtensions = ["image/jpeg", "image/jpg", "image/png", "video/mp4"]; //adding some valid image extensions in array
      if (validExtensions.includes(fileType)) { //if user selected file is an image file
      let fileReader = new FileReader(); //creating new FileReader object
      fileReader.onload = () => {
      let fileURL = fileReader.result; //passing user file source in fileURL variable
      let imgTag = ``; //creating an img tag and passing user selected file source inside src attribute
      let videoTag = ``;
      dragArea.innerHTML = imgTag; //adding that created img tag inside dropArea container
      dragArea.innerHTML = videoTag;
      }
      fileReader.readAsDataURL(file);
      } else {
      alert("This is not an Image File!");
      dragArea.classList.remove("active");
      dragText.textContent = "Drag and drop here to upload";
      }
      }
      But now only a video tag is created in html, although for example I clicked on a picture = video tag, and in src - a picture (( ( How to fix?? Help, please!

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

    thanks man! really helpful

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

    When displaying the image the input is lost, how can I keep it to publish by button?

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

    Ek number

  • @skygrace8459
    @skygrace8459 2 года назад

    Thanks for the tutorial, so please let next about multiple upload with preview, delete and add button

  • @cristhianzamalloa2729
    @cristhianzamalloa2729 2 года назад

    Thank you very much. The best explanation that I've found. Really good.

  • @HabiburRahman-fw5vr
    @HabiburRahman-fw5vr 3 года назад +1

    That's great. It was very helpful.💕❤️

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

    Nice thanks man!

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

    That's great. It was very helpful.

  • @moizghazali8852
    @moizghazali8852 2 года назад

    Really needed

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

    Cool video, keep it up

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

    Great video ,, keep it up bro

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

    Can you click the box area too?

  • @mukulchaudhary27
    @mukulchaudhary27 2 года назад

    how do we validate that on drag and drop the file/attachment is successfully loaded in our input filed which is hidden, because we need to send data to the server or need to other stuff

  • @yadhukrishna9839
    @yadhukrishna9839 2 года назад

    instead of image what extension needs to be used for a pdf file

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

    Amazing video

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

    how i can add for exp, logo on the top? i can't do it...

  • @romuloalves9349
    @romuloalves9349 3 года назад +3

    Ótimo vídeo parabéns ✌.

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

    You are awesome💕💕

  • @shashanksundi5669
    @shashanksundi5669 2 года назад

    Thank You

  • @AshishKumar-wh6dw
    @AshishKumar-wh6dw 3 года назад +1

    Amazing !!

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

    Can I put the file name in this like the video 'Preview Image before upload'?
    I want to make it by applying two videos.

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

    Thank you for your awesome video :)

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

    hello thanks alot for this video, im trying to do similar thing for my senior project , i was wondering if i want to insert more than one file, is it possible ?

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

    this is great , bro how to add up numbers in input boxes

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

      const input1 = document.querySelector("#input1");
      const input2 = document.querySelector("#input2");
      console.log(input1.value + input2.value);

  • @harunonur3371
    @harunonur3371 2 года назад

    Thanks.

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

    Hi..!!.. How can i link the Input to a php script to upload the image on a server..??.. I named the input to link it to a php variable but it don't works :c

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

      Watch this video for it: ruclips.net/video/_xDCVt1F6O0/видео.html

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

      @@CodingNepal Thank you..!!..

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

    Just awesome ❤️ 🔥 bro....... But why was the video late?🤔

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

    Nice!!

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

    When you drag and drop the file is it left in a download folder?

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

      I didn't understand. Can you please explain more.?

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

    How to post this image for further use ?

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

    Awesome bro ❤️
    Bro mera b Chanel hai web design ke related

  • @saad_o_6101
    @saad_o_6101 2 года назад

    can we drag or upload multiple files?

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

    Thx

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

    Thank you 🔥🔥🔥

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

    Bhai image direct upload Nahi ho Sakti Kya

  • @josephjayeoba7985
    @josephjayeoba7985 Месяц назад

    I love the song

  • @edwardjoseph1759
    @edwardjoseph1759 2 года назад

    Can you pls make one so that when the user reloads the page the image still remains

  • @augustoeduardo209
    @augustoeduardo209 2 года назад

    nice music

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

    Just Love it

  • @sithurukawinda
    @sithurukawinda 5 месяцев назад

    super

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

    is it work for videos too or not ??? if not plz make one how to upload video file in db

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

      No it's not work for video. This is only for image file

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

    close or cancel upload image ?❤️

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

      I didn't code for it because I already did it in my previous video ruclips.net/video/AYjOyQhZiK0/видео.html

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

      crop image and save image in database sir.?

  • @Salty_Playzz
    @Salty_Playzz 2 года назад

    Hello sir I am unable to run the php with this plz
    How to run php files.🙏🏻🙏🏻🙏🏻

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

    you are epic!!!

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

    How to make PDF viewer using HTML CSS and js

  • @НатальяАлфёрова-и6т

    Спасибо!

  • @SonNguyen-rb4ut
    @SonNguyen-rb4ut 3 года назад +2

    I want to send that image to server. How can i do it when don't have input tag. Thank you for reading my question. 😘😘

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

      You've to use php move_uploaded_file() function to upload/move it.

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

      ​@@CodingNepal How I can do it, could you explain me?

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

    Thank's for video ! Could you please create dropdown bar with searching engin? each dropped document file searchable with searching engin. thank's made tuto like it.

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

    how to send any type of file to the server?

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

      You can easily do this using PHP move_uploaded_file function and remember we do not store files in the database we just store the path of that file.

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

    How do i upload multiple files?

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

      I'm thinking to make separate video for it.

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

      @@CodingNepal waiting for this video

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

      @@CodingNepal Waiting for multiple files upload video great content thanks.

  • @النبراسالمبين
    @النبراسالمبين 3 года назад

    I don't understand the code. What do I need to learn in javascript to understand this code?

  • @unboxkarunadu372
    @unboxkarunadu372 2 года назад

    Tried with your code when i drag and dropped the file, getting file value as empty

    • @CodingNepal
      @CodingNepal  2 года назад

      You may did some mistakes. You can download the source codes file this project from here - www.codingnepalweb.com/drag-drop-file-upload-feature-javascript/

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

    nice 💙💙💙💙💙💙💙💙

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

    why are you adding this in all function --- dropArea.classList.remove("active");

  • @parabunx
    @parabunx 2 года назад

    how to recover file behind ?

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

    why my javascript is not working ?

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

      You can get codes from the description and check your codes with our codes or tell me the error that you may got in console.

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

    How to save the file?

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

      Means?

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

      @@CodingNepal The files need to be saved in some folder. It may be local machine or a server.

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

      @@CodingNepal Every you dragged, need to be saved somewhere. It could be local macine or a server.

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

    15:41 My image is not showing it is giving an error :
    Get ~image URL ~ 404 (Not Found)
    please help me to resolve error

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

      Same to me

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

      Have u find it

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

      @@gametime6965 yes there is a code where we have to write ` instead ' then you will not get the error

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

      @@mansisharma5365 now it's working... Thanks

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

    Linkd down....

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

    How do you edit multiple line at once? I can only edit multiple lines that are neighbours. Also how to deal with excel and other type of files Overall gr8 video!!

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

    cod not get bro

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

      Bro.. I've recently uploaded this video so codes will be available tomorrow... Please keep patience.

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

      @@CodingNepal please give this code bro

  • @4ia08_galuhachmadfauzan3
    @4ia08_galuhachmadfauzan3 2 года назад +1

    can you change the file type to excel and if you can can you tell me how?