How do I link to a downloadable file in CakePHP 3.6?
up vote
0
down vote
favorite
How do I link to a downloadable file in CakePHP 3.6? The file is webroot/files/filename.pdf
I can create the link using
$this->Html->link('Link text', '/files/filename.pdf');
but when I click on it, I get the message "FilesController could not be found.".
I've searched the documentation and online, but can't find any mention of this.
cakephp-3.0
add a comment |
up vote
0
down vote
favorite
How do I link to a downloadable file in CakePHP 3.6? The file is webroot/files/filename.pdf
I can create the link using
$this->Html->link('Link text', '/files/filename.pdf');
but when I click on it, I get the message "FilesController could not be found.".
I've searched the documentation and online, but can't find any mention of this.
cakephp-3.0
1
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How do I link to a downloadable file in CakePHP 3.6? The file is webroot/files/filename.pdf
I can create the link using
$this->Html->link('Link text', '/files/filename.pdf');
but when I click on it, I get the message "FilesController could not be found.".
I've searched the documentation and online, but can't find any mention of this.
cakephp-3.0
How do I link to a downloadable file in CakePHP 3.6? The file is webroot/files/filename.pdf
I can create the link using
$this->Html->link('Link text', '/files/filename.pdf');
but when I click on it, I get the message "FilesController could not be found.".
I've searched the documentation and online, but can't find any mention of this.
cakephp-3.0
cakephp-3.0
edited Nov 10 at 20:09
halfer
14.2k757105
14.2k757105
asked Oct 17 at 11:37
Sharon
84462549
84462549
1
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18
add a comment |
1
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18
1
1
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
You need to pass the download attribute in your anchor tag. For cakephp 3, you can pass it something like
$this->Html->link('Link text', '/files/filename.pdf',['download'=>'filename.pdf']);
or
$this->Html->link('Link text', '/files/filename.pdf',array('download'=>'filename.pdf'));
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
add a comment |
up vote
0
down vote
accepted
Thanks to David, I realised I was doing the right things as far as Cake was concerned, but was using the wrong file name and linking to a file that didn't exist on the server.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You need to pass the download attribute in your anchor tag. For cakephp 3, you can pass it something like
$this->Html->link('Link text', '/files/filename.pdf',['download'=>'filename.pdf']);
or
$this->Html->link('Link text', '/files/filename.pdf',array('download'=>'filename.pdf'));
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
add a comment |
up vote
1
down vote
You need to pass the download attribute in your anchor tag. For cakephp 3, you can pass it something like
$this->Html->link('Link text', '/files/filename.pdf',['download'=>'filename.pdf']);
or
$this->Html->link('Link text', '/files/filename.pdf',array('download'=>'filename.pdf'));
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
add a comment |
up vote
1
down vote
up vote
1
down vote
You need to pass the download attribute in your anchor tag. For cakephp 3, you can pass it something like
$this->Html->link('Link text', '/files/filename.pdf',['download'=>'filename.pdf']);
or
$this->Html->link('Link text', '/files/filename.pdf',array('download'=>'filename.pdf'));
You need to pass the download attribute in your anchor tag. For cakephp 3, you can pass it something like
$this->Html->link('Link text', '/files/filename.pdf',['download'=>'filename.pdf']);
or
$this->Html->link('Link text', '/files/filename.pdf',array('download'=>'filename.pdf'));
answered Oct 25 at 9:40
Rafi Ahmad
253
253
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
add a comment |
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
Thank you! That's helpful to know!
– Sharon
Oct 25 at 19:54
add a comment |
up vote
0
down vote
accepted
Thanks to David, I realised I was doing the right things as far as Cake was concerned, but was using the wrong file name and linking to a file that didn't exist on the server.
add a comment |
up vote
0
down vote
accepted
Thanks to David, I realised I was doing the right things as far as Cake was concerned, but was using the wrong file name and linking to a file that didn't exist on the server.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Thanks to David, I realised I was doing the right things as far as Cake was concerned, but was using the wrong file name and linking to a file that didn't exist on the server.
Thanks to David, I realised I was doing the right things as far as Cake was concerned, but was using the wrong file name and linking to a file that didn't exist on the server.
answered Oct 17 at 19:18
Sharon
84462549
84462549
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52853973%2fhow-do-i-link-to-a-downloadable-file-in-cakephp-3-6%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Is the file really at /files/filename.pdf? The message indicates that the file could not be found and therefore the app tries to apply the standard controller/action fallback route it, just to discover that this controller does not exist either.
– David Albrecht
Oct 17 at 15:08
Thank you! You were right - I had saved it with a different name on the fileserver! Can't believe it was something so simple, but I'll leave this here in case it helps anyone else at a later stage. Thanks again.
– Sharon
Oct 17 at 19:18