skip to Main Content

I have file in assets
Path to the asset
and i hope this file can download in my project

<button className='p-2 bg-green-600 my-3 text-white '>
    <href='../../../Assets/file/form_upload_lead.xlsx'>Download Format Upload</a>
</button>

module not found

i hope this file can download. when i download this file the result like this
Error on download

2

Answers


  1. Firstly, you need to use the correct syntax for the anchor <a> tag.

    Also, you might want to serve the file from a public folder that is accessible by the web server. Typically in Next.js, we use the public directory for this. Anything inside the public directory can be accessed via

    </filename>.
    <button className='p-2 bg-green-600 my-3 text-white '>
        <a href='/form_upload_lead.xlsx' download>Download Format Upload</a>
    </button>
    
    
    Login or Signup to reply.
  2. If the file is meant to be public it should be stored on the public folder or a subdirectory of it.

    • You will typically place the Assets folder on public folder
    • Then You can (access) download the file in the path /Assets/file/form_upload_lead.xlsx

    After that clicking directly to the link will trigger the download of the file:

     <button className='p-2 bg-green-600 my-3 text-white '>
       <a href='/Assets/file/form_upload_lead.xlsx'>Download Format Upload</a>
     </button>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search