JInput->files unreliable in Joomla 4

131 views
Skip to first unread message

Kenneth Genesis

unread,
Nov 25, 2022, 11:50:41 AM11/25/22
to Joomla! General Development
Howdy. I'm modernizing a corporate app from Joomla 3 to Joomla 4. The various user upload forms started failing randomly on some files leaving no error log. It was as if the file was never included in the upload.

BUT I found it in $_FILES. So PHP saw the file but Joomla did not.

After much hair-pulling, I found a comment that says Joomla may be filtering the results.
If this is true, I've hunted for a way to disable this filter.

For now, I've done a search and replace to remove $input->files and reach past Joomla to get $_FILES. I'm hoping this is temporary, but I can't roll this app out if it only works some times.

So ya, if anyone can point me to a way to just "get all files from input" I'm sure there's a simple parameter I couldn't find

Tomas Dalebjörk

unread,
May 23, 2023, 9:43:36 AM5/23/23
to Joomla! General Development
I have the same issue, where this does not work
$files = $this->input->files->get('data', [], 'array');

And this is where the form data is
 $app->input->get('jform')

So where is the actual file data? as $_FILES has it?

Mark Stanton

unread,
May 24, 2023, 4:29:36 AM5/24/23
to Joomla! General Development
I have this in the the template

<input required type="file" class='form-select' id="import-file" name="Filedata[]" multiple />

and then this in the controller

$files = $this->input->files->get('Filedata', [], 'array');

Allows me to multi-select a list of files and access their data.  All of them.  Always.

Tomas Dalebjörk

unread,
May 25, 2023, 8:08:01 AM5/25/23
to Joomla! General Development
Ok,

So not using the /forms/formname.xml which I did?
So why is there a "file" type in the form documented at Joomla, if no-one are able to use it?

Regards Tomas

Mark Stanton

unread,
May 26, 2023, 3:19:28 AM5/26/23
to Joomla! General Development
I'm sure you can use the xml type.  That should generate the same html as I used above.  The you just need to make sure the rest of the naming lines up.

Tomas Dalebjörk

unread,
May 27, 2023, 8:24:17 AM5/27/23
to joomla-de...@googlegroups.com, Mark Stanton

Thanks,

But I can't get it to work using the forms, only when I am not using the form.

Are there any real example where someone has made it work by using the form to actually upload a file?

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/0c69ad19-7c4e-459a-a00e-9d659801f307n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages