# Download Webroot File

**URL:** <https://discourse.cakephp.org/t/download-webroot-file/3295>\
**Category:** Need Help\
**Created:** [September 29, 2017, 9:52am UTC](https://discourse.cakephp.org/t/download-webroot-file/3295 "2017-09-29T09:52:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grunard](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@Grunard](https://discourse.cakephp.org/u/Grunard)\
**Post date:** [September 29, 2017, 9:52am UTC](https://discourse.cakephp.org/t/download-webroot-file/3295/1 "2017-09-29T09:52:37Z")

</div>

Hi guys, I need my page download a file in a folder in webroot to clients computer, I used “withDownload” but didn´t work. Please tell me the best method to do. Thanks

---

<div class="post-metadata">

**Author:** ![gildonei](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/gildonei/32/844_2.png) [@gildonei](https://discourse.cakephp.org/u/gildonei)\
**Post date:** [October 10, 2017, 7:45pm UTC](https://discourse.cakephp.org/t/download-webroot-file/3295/2 "2017-10-10T19:45:28Z")

</div>

Try this:

```
$filename = '.htaccess';
$response = $this->response->withFile(
    WWW_ROOT . $filename,
    ['download' => true, 'name' => $filename]
);
return $response;
```

---

<div class="post-metadata">

**Author:** ![sairaghuram.n](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sairaghuram.n](https://discourse.cakephp.org/u/sairaghuram.n)\
**Post date:** [November 23, 2023, 7:08am UTC](https://discourse.cakephp.org/t/download-webroot-file/3295/3 "2023-11-23T07:08:57Z")

</div>

Hey Guys, I have a similar kind of code but it is not downloading the file. Instead after clicking on the download button, it is not throwing an error or any thing … but it open the blank white page instead of downloading. Please help me with that. thanks in advance
