0

In my administrator/component folder, i have the a download.php file which performs downloading of a file from the browser. I have a link to the php file below:

<a href = "<?php echo JPATH_COMPONENT_ADMINISTRATOR.'/download.php';?>">download</a>

When i click the link, it does nothing,

but when I change it to this link below and move the file to C:\xampp\htdocs\BDES3\administrator\

<a href = "<? echo 'download.php';?>">download</a>

the link actually works.

Here is the code inside download.php file:

$file = 'E:\hello.txt';

if (file_exists($file)) {
     header('Content-Disposition: attachment; filename='.basename($file));
     readfile($file,false);
    exit;
}

I am trying to download a sample file when I click the link.

Is there something wrong with my code? or does it have something to do with directories in Joomla? or are there easier ways in downloading files from joomla?

0

By default, Joomla provides a .htaccess file with several definitions and security restrictions.

index.php is the main entry point, and there are several additional restrictions to avoid executing any arbitraty php file.

Just to test, remove the .htaccess and execute download.php. Once you confirm how it works, be extra careful to configure the .htaccess and keep the site secure.

An extension for site administration, like Akeeba Admin tools, allows to reconfigure the .htaccess, adding more rules or exceptions to allow direct access to specific files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.