href image link download on click

后端 未结 10 1806
失恋的感觉
失恋的感觉 2020-11-22 07:56

I generate normal links like: in a web app.

When I click on the link, it

相关标签:
10条回答
  • 2020-11-22 08:51

    If you are Using HTML5 you can add the attribute 'download' to your links.

    <a href="/test.pdf" download>
    

    http://www.w3schools.com/tags/att_a_download.asp

    0 讨论(0)
  • 2020-11-22 08:51

    Simple Code for image download with an image clicking using php

    <html>
    <head>
        <title> Download-Button </title>
    </head>
    <body>
        <p> Click the image ! You can download! </p>
        <?php
        $image =  basename("http://localhost/sc/img/logo.png"); // you can here put the image path dynamically 
        //echo $image;
        ?>
        <a download="<?php echo $image; ?>" href="http://localhost/sc/img/logo.png" title="Logo title">
            <img alt="logo" src="http://localhost/sc/img/logo.png">
        </a>
    </body>
    
    0 讨论(0)
  • 2020-11-22 08:52

    Image download with using image clicking!

    I did this simple code!:)

    <html>
    <head>
    <title> Download-Button </title>
    </head>
    <body>
    <p> Click the image ! You can download! </p>
    <a download="logo.png" href="http://localhost/folder/img/logo.png" title="Logo title">
    <img alt="logo" src="http://localhost/folder/img/logo.png">
    </a>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-11-22 08:53
    <a download="custom-filename.jpg" href="/path/to/image" title="ImageName">
        <img alt="ImageName" src="/path/to/image">
    </a>
    

    It's not yet fully supported caniuse, but you can use with modernizr (under Non-core detects) to check the support of the browser.

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