my code stock.com

alafos

K2 Download Item Attachment Broken
by alafos

K2 v2.6.7, Joomla 2.5.XX, Download Item Attachment Broken on Frontend and Backend. Received: "File does not exist"
In: administrator/components/com_k2/models/item.php
file is stored in DB with full path eg: /var/www/html/... ($attachment->filename)
then $savepath is being prepended to it.

Snippet options

Download: Download snippet as k2-download-item-attachment-broken.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

Line 1066:
Before:

$file = $savepath.DS.$attachment->filename;

After: (make sure we stay in JPATH_ROOT to avoid pulling system files)

$file = $attachment->filename;
if (strpos($file, JPATH_ROOT) !== 0) {
    $file = $savepath.DS.$attachment->filename;
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.