javascript - Codeigniter adds index.php to a download url -
i trying make button when pressed calls javascript function downloads file.
download code:
function downloadfile(url) { console.log('clicked'); var iframe; iframe = document.getelementbyid("download-container"); if (iframe === null) { iframe = document.createelement('iframe'); iframe.id = "download-container"; iframe.style.visibility = 'hidden'; document.body.appendchild(iframe); } iframe.src = "uploads/img/"+url; }
button code:
<?php echo '<button type="button" onclick="downloadfile(\''.$value.'\')">'.$value.'</button>' ?>
the output is:
get http://localhost/dfi/index.php/uploads/img/mux.png 404 (not found)
because index.php added url, when remove index.php , access file directly in browser can access normally.
try :
iframe.src = "/uploads/img/"+url;
or add full url src :
iframe.src = "http://localhost/dfi/uploads/img/"+url;
Comments
Post a Comment