I have a Submit button (Materialize Framework) which should perform two task:
-
execute a python Query
-
Download an excel file which is present in my folder path: C:\wamp64\www\Project\
Previously, I did try code mentioned below, which is downloading the excel:
<div class="button-container">
<button class="btn waves-effect waves-light btn-small"
type="submit" name="action" style="background-color: #424242; ">
<a href="Format 1.xlsx" target="_new" download="Format 1.xlsx">
<strong>Submit</strong>
</a>
<i class="material-icons right">file_download</i>
</button>
</div>
I tried to execute two task at the same time.
The following is the code which I tried and it is executing the python script but not downloading the excel:
<?php
if(isset($_POST['update'])){
echo "I am working";
exec(
'"C:\Users\Sonal Mulani\AppData\Local\Programs\Python\Python36\python.exe"
C:\wamp64\www\BillingPortalNew\Pivot1.py'
);
echo "Script exec";
}
?>
<div class="button-container">
<form name="update" method="post" >
<button class="btn waves-effect waves-light btn-small"
type="submit" name="update" style="background-color: #424242; ">
<a href="Format 1.xlsx" target="_new" download="Format 1.xlsx" id="abc"><strong>Submit</strong>
</a>
<i class="material-icons right">
file_download
</i>
</button>
</form>
</div>
For downloading the excel I tried by assigning an id=abc to tag and calling it at the end:
</body>
<script>
jQuery(function(){
jQuery('#abc').click();
});
</script>
</html>
Is there a solution to download the excel as well as executing the python script?