JFactory::getApplication()->input empty

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
sanitar
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Aug 27, 2014 3:42 pm

JFactory::getApplication()->input empty

Postby sanitar » Tue Nov 28, 2017 3:59 pm

good afternoon.
component is my own. everything works, the data write into db. I try to add a field to the file for uploading. I read that after sending, I need to process the file in the prepareTable method
Added the following code to the model file:

Code: Select all

protected function prepareTable(&$table){

$jinput = JFactory::getApplication()->input;
$files = $jinput->post->get('jform');
$file   = $files;
$filename = "/log.txt";
$string = $file;
$f = fopen($filename,"a+");
fwrite($f,$string);
fclose($f);
}


$file turns out to be empty. is not even an array. What have I done wrong?

User avatar
mbabker
Joomla! Hero
Joomla! Hero
Posts: 2042
Joined: Sun Feb 28, 2010 8:26 pm
Location: White Bear Lake, MN, USA
Contact:

Re: JFactory::getApplication()->input empty

Postby mbabker » Tue Nov 28, 2017 5:50 pm

If this is a file upload then you need to read the data from the $_FILES superglobal, accessed via $jinput->files->get('foo')
Production Department Coordinator, Release Lead, CMS Maintainer, Framework Maintainer, Security Team Member, .org System Administrator

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281

sanitar
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Aug 27, 2014 3:42 pm

Re: JFactory::getApplication()->input empty

Postby sanitar » Tue Nov 28, 2017 11:54 pm

yes,it's file upload
i tried to use the construction

Code: Select all

$jinput = JFactory::getApplication()->input;
$files  = $jinput->files->get('jform');
$file   = $files['myfilevalue']


but it not work
and yes,form contains enctype="multipart/form-data"


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 3 guests