Welcome Guest, Not a member yet? Register   Sign In
Get folder path instead of url path
#1

(This post was last modified: 05-18-2024, 07:00 AM by pippuccio76.)

i i want download file from server , i create a link:

Code:
<a href="<?=WRITEPATH.'uploads/report/'.$doa->id.'/'. $doa->numero ?>" class="btn btn-info ms-3" download>DOWNLOAD FILE</a>



But if i see the link i have  :

[CODE]

https://my_site/home/uz2lnhpx/domains/my_subdomain/public_html/codeigniter/writable/uploads/report/32/1003_General.xlsx
[/CODE]
instead of :

Code:
/home/uz2lnhpx/domains/my_subdomain/public_html/codeigniter/writable/uploads/report/32/1003_General.xlsx
And chrome show that file there isn't...
Reply
#2

You cannot reach WRITEPATH from public folder. You should do this instead:


PHP Code:
    public function downloadReport($id$numero)
    {
        $file WRITEPATH 'uploads/report/' $id '/' $numero;
        $data file_get_contents($file);
        $this->response->setHeader('Content-Type'mime_content_type($file));
        $this->response->setHeader('Content-Disposition''attachment; filename="'.$numero.'"');
        return $this->response->setBody($data);
    
Reply
#3

I want download by click on button not change page to download
Reply
#4

(This post was last modified: 05-18-2024, 07:47 PM by ozornick.)

Create new folder in public/uploads, set 777 chmod. Done.
Simple CI 4 project for beginners codeigniter-expenses
Reply
#5

(This post was last modified: 05-20-2024, 03:58 AM by pippuccio76.)

(05-18-2024, 07:47 PM)ozornick Wrote: Create new folder in public/uploads, set 777 chmod. Done.

is not a permission problem is a path problem (give 777 same problem)



for example on localhost i have this path localhost:8080/home..... there isn't a s.o folder named localhost:8080

Reply
#6

From the browser, you can only see files from the public/*** folder. Not writable, vendor, tests,...
There is another problem if you change the save path to public/uploads?
Simple CI 4 project for beginners codeigniter-expenses
Reply




Theme © iAndrew 2016 - Forum software by © MyBB