Skip to main content

Product file upload fails on Joomla 6.1.3+ for ZIP files: "File not uploaded for

2 hours 5 minutes ago #100000783 by JanDerhake
-- HikaShop version -- : 6.8.2
-- Joomla version -- : 6.2.0
-- PHP version -- : 8.3
-- Browser(s) name and version -- : all

Hello,

since Joomla 6.1.3 we can no longer upload ZIP files as product files (downloads) in the backend product edit page. We sell Joomla extensions, so our product files are ZIP packages that contain PHP files.

Environment: Joomla 6.2.0, HikaShop Business 6.8.2 (build of 2026-11-20), PHP 8.3. The code is the same in 6.5.2, 6.6.0 and 6.7.1.

Steps to reproduce:
1. Backend, edit a product, block "Images and Files", files area.
2. Upload a small ZIP that contains PHP files (any Joomla extension package, e.g. 100 KB).

Result:
- "New file" popup (link button, mode "Upload file", then OK): the popup shows a Joomla error page:
  Joomla\Filesystem\File::upload: File not uploaded for security reasons!
- Upload button and drag & drop: the progress bar turns red at "100%", there is no error message, and the file is not added. The AJAX request (ctrl=upload&task=upload) returns HTTP 500 with an HTML error page.

Cause:
Since joomla/filesystem 4.2.x (Joomla 6.1.3), Joomla\Filesystem\File::upload() runs File::isSafeFile() unless the 4th parameter $allowUnsafe is true. For archives (zip, rar, tar, gz, tgz, bz2, tbz, jpa) isSafeFile() scans the whole content for ".php", ".pl", ".py" and similar strings. A ZIP with PHP files in it is always rejected, and a ZIP without PHP can be rejected by chance because the compressed data contains such a string.

HikaShop calls File::upload($src, $dest) without that parameter:
- administrator/components/com_hikashop/helpers/upload.php, lines 188 and 427
- administrator/components/com_hikashop/classes/file.php, lines 106 and 207
- also controllers/plugins.php line 401 and helpers/import.php line 314

Why it worked before:
Up to HikaShop 6.4.1 these calls were JFile::upload(...). That legacy class returns false for an "unsafe" file, so your fallback

  if(!JFile::upload(...)) { if(!move_uploaded_file(...)) { ... } }

stored the file. Since 6.5.2 the calls use \Joomla\Filesystem\File::upload(...), which throws a FilesystemException instead of returning false. The move_uploaded_file() fallback is never reached.

Suggested fix:
1. For product files (type "file"), call File::upload($src, $dest, false, true), or pass ] as 5th parameter so that archive contents are not scanned. The files go to the secure upload folder, are filtered by the HikaShop setting for allowed file extensions, and only backend users with product edit rights can upload.
2. Wrap the calls in try/catch, so that the fallback works again and the user gets a readable error message in the AJAX uploader instead of a red bar without text.

Current workaround on our side: upload the file by FTP to the secure upload folder and select it with the "+" button.

Thank you,
Jan Derhake

Please Log in or Create an account to join the conversation.

Time to create page: 0.046 seconds
Powered by Kunena Forum