Do you also want to install some kind of Auto Downloading System in your website, like you mentioned, how can you implement a script to auto download files like Image, Picture, PDF, Video, exe file, etc., for this we have given below. have coded

Javascript download file automatically | image auto download javascript

In the Anchor (A) Tag given below, we have given the URL of a file which we have to auto download, when there is a URL of a file in this href=”” it will be auto downloaded, apart from this you can enter the condition through if command. set, which will work only on the command given by you.

Without Any Condition File Auto Download,

<a href="upload/1663332102.jpg" id="down123" download="">
<img src="upload/1663332102.jpg" width="auto" height="auto"></a>

<br>

<script>
            document.getElementById('down123').click(); 
        </script>

.If Condition With File Download Automatically

<?php if($file==true){ ?>
<a href="upload/<?php echo $file; ?>" id="down123" download="">
<img src="upload/<?php echo $file; ?>" width="auto" height="auto"></a>
<?php } ?>
<br>

<script>
            document.getElementById('down123').click(); 
        </script>

In this way you can download any type of file by using the above code.

Leave a Reply

Your email address will not be published. Required fields are marked *