Open A File Via Html Button

后端 未结 3 1762
长情又很酷
长情又很酷 2021-01-29 14:06

I am looking for a way to open a file when user clicks on the open button on my website.

Basically, I want to define the path to that specific file tha

相关标签:
3条回答
  • 2021-01-29 14:43
    <a href="/filepath/file.pdf" target="_blank"><input type="button" value="Open File" /></a>
    
    0 讨论(0)
  • 2021-01-29 14:50

    I have read about it in another post. Try using this:

    <a href="path_to_file" download="proposed_file_name">Download</a>

    Where :

    path_to_file is either an absolute or relative path, proposed_file_name the filename to save to (can be blank, then defaults to the actual filename).

    Hope it helps

    0 讨论(0)
  • 2021-01-29 14:56

    Using

    <input type="file" id="file" name="file" />
    

    you can open up a file dialog. You'll have to handle this with PHP. This link: https://www.sitepoint.com/handle-file-uploads-php/ provides all the info you need. If you don't have a server to upload .php files to, you can set up a LAMP server.

    Hope this helps :)

    0 讨论(0)
提交回复
热议问题