Welcome Guest, Not a member yet? Register   Sign In
Force download of image
#1

Hi , sorry for english , i want create a link to download image and pdf from server folder .

This is the code :
Code:
<?= $v->nome_file_originale ?><a download="<?= $v->nome_file_originale ?>" href="<?=base_url() ?>/uploaded/xyz_xrh/documenti/<?=$record->id_users?>/<?= $v->nome_file ?>" >Download</a>

it work only with pdf ...
Reply
#2

Add "download" attribute to the link.
Reply
#3

(10-14-2021, 04:41 AM)ARAmiss Wrote: Add "download" attribute to the link.

there is download...
Reply
#4

What's your link look like in html page source (in browser)?
Reply
#5

Please read the CodeIgniter 4 User Guide.

CodeIgniter 4 User Guide - Force File Download
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

pippuccio76 use base_url, so it seems files stored in public folder, it is enough for him to give away a picture using a web server. Not build response from img.
Reply
#7

(This post was last modified: 10-15-2021, 09:55 AM by pippuccio76.)

(10-15-2021, 12:46 AM)InsiteFX Wrote: Please read the CodeIgniter 4 User Guide.

CodeIgniter 4 User Guide - Force File Download

But i must use it on an html page not redirect to another page .... is there a way to use an anchor ?

(10-15-2021, 01:11 AM)ARAmiss Wrote: pippuccio76 use base_url, so it seems files stored in public folder, it is enough for him to give away a picture using a web server. Not build response from img.

base_url work only to show image not to download....
Reply
#8

According to this you just need to add the download attribute.

How to force a file to download instead of open in the browser using only HTML

Chrome will not allow cross orgin downloads.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

But which is the correct path ? the file is in /uploaded , at the same level i have the codeigniter folder (inside there are app,system,vendor and writable) . i try FCPATH ,base_url() but dont work...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB