Download Any File From URL in HTML and JavaScript

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • In this short tutorial, you'll learn how to download any file from URL using HTML and JavaScript. If the URL isn't publicly accessible, you might get a CORS error, indicating the browser has blocked access to the file. You can try downloading publicly accessible files from sites like Pixel and Unsplash.
    Follow me on Instagram
    / coding.np
    Hire me on Fiverr
    www.fiverr.com...
    Visit my website for helpful coding projects with source code
    www.codingnepa...
    Music credit:
    Wanderlust - CRASTEL
    • Wanderlust - CRASTEL |...
    #coding #javascript #js #htmlcss #react #reactjs #node #nodejs #html #css #jstips #backend #javascripttips #shorts #webdevelopment #typinganimation #webdeveloper #webdesign #frontend #codingforbeginners #cssanimation #csseffect #javascriptprojects #jsproject #codingnepal #how #howto #howtomake

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

  • @philippm8039
    @philippm8039 Год назад +40

    Most browsers will block it because of CORS.

  • @tykunal
    @tykunal Год назад +7

    I am surprised how this person doesn't have a CSS file created but still his screen has a bg color, most importantly not the default one.

    • @TOONSSTATION
      @TOONSSTATION 5 месяцев назад +1

      Use your mind.

    • @tykunal
      @tykunal 5 месяцев назад +2

      ​@@TOONSSTATION Oo , The great Programmer among all, please take the first step of telling us all.🙏

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

      ​@@tykunal I can only guess, but it's probably his browser theme

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

      @@spaceflightquack Yeah bro, you are right! 👍

    • @tykunal
      @tykunal 7 дней назад

      ​@@CHITRADAMOHANVAMSIC 😅 bro where are you seeing the inline css?
      It is the browser's theme.

  • @Spinutzerr
    @Spinutzerr Месяц назад +1

    can you write the code in the description because its not working 😢

  • @anavadiyakush777
    @anavadiyakush777 Год назад +1

    Nice work, i will be subscribed you ❤🇮🇳

  • @IceMetalPunk
    @IceMetalPunk Год назад +4

    Why are you setting the "download" attribute to the current time? Setting it to true would be enough... Also, I wouldn't say "any file from URL": CORS settings will break this for most cross-domain URLs.

  • @CodingMobile
    @CodingMobile Год назад +7

    Not working 😢.

  • @mathivananbakthavachalu4368
    @mathivananbakthavachalu4368 Год назад +1

    Love your content...keep up your 👍

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

    This syntax makes my brain itch

  • @MenghebatGratis20
    @MenghebatGratis20 Год назад +1

    Nice work 🎉

  • @mhhamzaedits
    @mhhamzaedits 9 месяцев назад

    Awasome bro ❤❤

  • @andriiukraine6697
    @andriiukraine6697 Год назад +2

    Remake of "Save" button?)

  • @bhishek_
    @bhishek_ Год назад +7

    Can we download youtube videos also?

    • @L1CBot
      @L1CBot Год назад +6

      no, infact this project is not too useful just how you are thinking

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

      @@L1CBot 😁🫠

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

      For youtube videos you need libraries to download, but some youtube videos are protected not downloadable

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

      ​@@fluffybunny510you can open dev tools and just copy the url

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

      ​@@bhishek_😂😂

  • @percussion1999
    @percussion1999 2 месяца назад

    Great

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

    perfect ❤

  • @karthiksriramkosuri3437
    @karthiksriramkosuri3437 10 месяцев назад +1

    Not working

  • @yashbanait...7277
    @yashbanait...7277 Год назад +1

    What is CORS??

  • @jahirrana8879
    @jahirrana8879 Год назад +1

    I have apply this code there show me "cors policy error" what need i do now?

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

      Depends where are you hosting the web site and what CORS policy has the target to download.

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

    👍👍

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

    where did i get source code

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

    can someone tell me how to add cors permissions using curl to the same code

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

    Bro all coding need where to find????

  • @simont733
    @simont733 8 месяцев назад

    How to automaticaly copy the link and download

  • @2XDark
    @2XDark 11 месяцев назад

    How to paragraph link

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

    Save to galery?

  • @admdebases-rudye.p.6773
    @admdebases-rudye.p.6773 Год назад +2

    y la explicacion de cada paso ???

    • @AquaFireGhost
      @AquaFireGhost Год назад +1

      1. El botón tiene un eventlistener al click
      Al hacer click:
      2. Se lee el valor del input text (el link escrito pues) y se espera que fetch retorne un Response
      3. Se espera que el Response retorne un BLOB (secuencia en bytes del recurso a descargar)
      4. Se crea un elemento
      5. El elemento tiene como href un url al BLOB (con ese url ya se puede descargar)
      6. Se habilita que el elemento descargue un archivo en el equipo (link.download=true)
      7. link.click() Simula el click hecho al elemento , y teniendo download=true se descarga el recurso en el equipo

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

    nice

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

    how to download youtube videos?

  • @blueGD
    @blueGD Год назад +2

    I mean why? CORS would block it and it would just be easier to paste the url in the search bar lol 😂. Or you could just use curl or wget and no cors problems 😅

  • @navneetnic007
    @navneetnic007 4 месяца назад

    youtube video nahi ho raha h

  • @bassammegubli392
    @bassammegubli392 Год назад +2

    If we paste a webpage it won't fetch the desired content but the html page right?

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

      Yes, if the link goes to a webpage instead of a resource, it will return an html document

  • @khawajaabubaker1775
    @khawajaabubaker1775 8 месяцев назад

    its don,t work

  • @DaMu24
    @DaMu24 Год назад +1

    Misleading

  • @ok.nandesh
    @ok.nandesh Год назад

    This project download file link 😊