How to get file tmp_name using JInput - file-upload

I'm a bit stuck with this. I have this bit of code which manages to get the filename of my file:
class AControllerA extends JControllerForm
{
function save()
{
//Upload file
jimport('joomla.filesystem.file');
$jinput = JFactory::getApplication()->input;
$store_form = $jinput->get('jform', null, 'array');
$file = $store_form['img_url'];
echo $file;
}
}
*The file field has a name of jform[img_url];
However I cannot seem to get the 'tmp_name' for the file. Anyone know what I'm missing out? I'm a bit confused as to how jinput works...jrequest worked quite easily. Thanks!
models/forms/a.xml
<form enctype="multipart/form-data">
<fieldset>
<field
name="img_url"
type="file"
label=""
description=""
size="40"
class="inputbox"
default=""
/>
</fieldset>
</form>

How about like this:
$files = $input->files->get('jform', null);
$filename = $files['img_url']['tmp_name'];
echo $filename;
Check out documentation for Retrieving file data using JInput

Supposing you are using JForm and the file input type, then you can access the file using this:
$files = $jinput->files->get('jform');
$file = $files['img_url']['tmp_name']
Also make sure your form has the enctype="multipart/form-data" set, otherwise it will not work.

In your model you should have sth like this
public function getForm($data = array(), $loadData = false)
{
/**
* Get the Form
*/
$form = $this->loadForm('com_mycomponent.mycomponent', 'mycomponent',
array('control' => false, 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
Note that $loaddata and 'control' is set to false, when 'control' is false you can get file parameters as according to the name specified in your xml i.e the output form is like:
<input name="name in xml file" type="file" />
If 'control' => 'jform'
<input name="jform[name in xml file]" type="file" />
$loaddata= false means you dont need to fetch any data from the database to the form.
in your view.html.php you should have sth like this
public function display($tpl = null)
{
$this->formData = $this->get('Form');
$this->addToolbar();
parent::display($tpl);
}
Lets suppose I'll receive the requested file in "upload" method of "mycomponent" controller then it should have sth like this:
class MycomponentControllerMycomponent extends JControllerAdmin
{
public function upload()
{
//Retrieve file details from uploaded file, sent from upload form
$file = JFactory::getApplication()->input->files->get('name in xml
**$tmp_name** = $file['tmp_name'];
}
}
$tmp_name is Your required name

Related

How do I setup Birthdates using Yii3 and its Cycle-ORM integration?

Preconditions
mySql database client_birthdate field set as DATE and nullable if user does not enter date.
User inputs Client's Birthdate on __form textbox as a string in mySql format YYYY/MM/DD or not.
Yii3's ClientForm gets the string or empty string and converts to DATETIME so that Cycle Orm can process it.
Yii3's ClientService saves the date using Cycle's Client Entity's getter and setter methods and annotations.
Php 7.4.9
Typed property. Previously php allowed this variable declaration below a class public $var; now inserting typed property between public and $var ie public ?string $var = '' excludes other types. Question mark before type allows for null value input. So only two alternatives.
Understanding mySql's '0000-00-00' for non date input.
Download fork of https://github.com/yiisoft/yii-demo
dateHelper.php (adapted from Invoiceplane)
/**
* #return string|null
*/
public function date_from_mysql($date, $s)
{
//if previous input was not a date mySql would have input '0000-00-00'
if ($date <> '0000-00-00') {
//CYCLE converts all dates to DateTimeImmutable
$date = DateTime::createFromImmutable($date);
//$date = DateTime::createFromFormat('Y-m-d', $date);
//eg. $date->format('Ymd')
return $date->format($s->setting('date_format'));
}
return $date;
}
return '';
}
__form.php caption
<div class="mb-3 form-group has-feedback">
<label form-label for="client_birthdate"><?= $s->trans('birthdate'); ?></label>
<?php
$bdate = $body['client_birthdate'] ?? null;
if ($bdate && $bdate != "0000-00-00") {
//use the DateHelper
$datehelper = new DateHelper();
$bdate = $datehelper->date_from_mysql($bdate, false, $s);
} else {
$bdate = null;
}
?>
<div class="input-group">
<input type="text" name="client_birthdate" id="client_birthdate" placeholder="1900/12/01"
class="form-control data-datepicker"
value="<?= Html::encode($bdate); ?>">
<span class="input-group-addon">
<i class="fa fa-calendar fa-fw"></i>
</span>
</div>
</div>
Entity/Client.php
declare(strict_types=1);
namespace App\Invoice\Entity;
use \DateTime;
/**
* #Entity(
* repository="App\Invoice\Client\ClientRepository",
* mapper="App\Invoice\Client\ClientMapper",
* constrain="App\Invoice\Client\Scope\activeScope"
* )
* #Table(
* indexes={
* #Index(columns={"client_active"}),
* }
* )
*/
class Client
{
/**
* #Column(type="date", nullable=true)
*/
private $client_birthdate = '';
//CYCLE converts all date formats ie. DATE, DATETIME, to DateTimeImmutable so
work with DateTimeImmutable
public function __construct($client_birthdate = '')
public function getClient_birthdate() : ?DateTimeImmutable
{
if (isset($this->client_birthdate) && !empty($this->client_birthdate)){
return $this->client_birthdate;
}
if (empty($this->client_birthdate)){
return $this->client_birthdate = null;
}
}
public function setClient_birthdate(?\DateTime $client_birthdate): void
{
$this->client_birthdate = $client_birthdate;
}
Client/ClientForm.php
declare(strict_types=1);
namespace App\Invoice\Client;
use Yiisoft\Form\FormModel;
use Yiisoft\Validator\Rule\Required;
use \DateTimeImmutable;
use \DateTime;
final class ClientForm extends FormModel {
private ?string $client_birthdate = null;
public function getClient_birthdate(): ?\DateTime
{
if (isset($this->client_birthdate) && !empty($this->client_birthdate)){
return new DateTime($this->client_birthdate);
}
if (empty($this->client_birthdate)){
return $this->client_birthdate = null;
}
}
Client/ClientService
<?php
declare(strict_types=1);
namespace App\Invoice\Client;
use App\Invoice\Entity\Client;
use App\User\User;
final class ClientService
{
private ClientRepository $repository;
public function __construct(ClientRepository $repository)
{
$this->repository = $repository;;
}
public function saveClient(User $user, Client $model, ClientForm $form): void
{
$model->setClient_birthdate($form->getClient_birthdate());
Things to look out for:
Ensure _form 'id' and 'name' values eg. client_birthdate correspond to Entity #column and Database tables fields. ie Use field names consistently
through Entity, Annotations. The ClientForm's getter method will receive data from the __form which is a string or null. The getter will convert this to a DATETIME or null so that CYCLE ORM (Spiral Framework) can process it.
Ensure initialization in Entity/Client.php instantiation area ie. BEFORE construct and IN construct.
Tips
Annotations above function are read by Cycle's annotations.
use \DateTime; before Annotations. Don't forget backslash to indicate DateTime is a php class not in current Namespace.
mySql type DATE in database and 'date' included in annotation below. ie. * #Column(type="date", nullable=true) otherwise Cycle will not be able to read it.
I have elected to use a simple untyped, nullable string.
.../Entity/Client.php
public function getClient_birthdate() : ?\DateTimeImmutable
and
public function setClient_birthdate(?\DateTime $client_birthdate): void
...src/Invoice/Entity/Client.php...
/**
* #Column(type="date", nullable=true)
*/
private $client_birthdate = '';
The value accepted from coalface __form uses a string so initialize ClientForm.php's private ?string $client_birthdate = null with a string
not a DateTime function.
Question mark before ?\DateTime allows for null value. Use consistently in function declaration as well as seen below.
...src/Invoice/Client/ClientForm.php
public function getClient_birthdate(): ?\DateTime
{
if (isset($this->client_birthdate) && !empty($this->client_birthdate)){
return new DateTime($this->client_birthdate);
}
if (empty($this->client_birthdate)){
return $this->client_birthdate = null;
}
}
The above code can be reduced to:
public function getClient_birthdate() : ?\DateTime
{
// convert the input string on the form received by means of '$this->client_birthdate'
// back into DateTime so that Cycle can deal with it and
// save it in 'date' format in mysql behind the scenes
return new DateTime($this->client_birthdate);
}
Update 21 September 2022
Attributes are preferred now to annotations so above code has changed.
Essentially, to represent a DateTimeImmutable on a form it must be presented with the ->format() command. A suitable style of date must be between the brackets eg. Y-m-d or even d-m-Y. To accomplish this, additional code may be used eg.
__form.php
<div class="mb-3 form-group has-feedback">
<?php
$bdate = $datehelper->get_or_set_with_style($body['client_birthdate']);
?>
<label form-label for="client_birthdate"><?= $s->trans('birthdate') .' ('.$datehelper->display().')'; ?></label>
<div class="input-group">
<input type="text" name="client_birthdate" id="client_birthdate" placeholder="<?= ' ('.$datehelper->display().')';?>"
class="form-control input-sm datepicker" readonly
value="<?= null!== $bdate ? Html::encode($bdate instanceof \DateTimeImmutable ? $bdate->format($datehelper->style()) : $bdate) : null; ?>" role="presentation" autocomplete="off">
<span class="input-group-text">
<i class="fa fa-calendar fa-fw"></i>
</span>
</div>
</div>
Include the following datepicker jquery code in your layout file.
<?php
// https://api.jqueryui.com/datepicker
$js1 = "$(function () {".
'$(".form-control.input-sm.datepicker").datepicker({dateFormat:"'.$datehelper->datepicker_dateFormat()
.'", firstDay:'.$datehelper->datepicker_firstDay()
.', changeMonth: true'
.', changeYear: true'
.', yearRange: "-50:+10"'
.', clickInput: true'
.', constrainInput: false'
.', highlightWeek: true'
.' });'.
'});';
echo Html::script($js1)->type('module');
?>
Here is reference to the styles.
INVOICEPLANE SOLUTION
A Database Error Occurred Error Number: 1525 Incorrect DATE value: '0000-00-00' fix error 58 El error se debe al modo sql, que puede ser un modo estricto
solution permanent to Incorrect DATE value: '0000-00-00' change thsis data example > 1970-01-01
invoiceplane/application/modules/invoices/models/Mdl_invoices.php
or temporal solution mysql SET GLOBAL sql_mode = '';
ubuntu 20.04
mysql 8

Empty post value : CodeIgniter

While uploading the file through codeigniter, I am getting the following error:
My file upload result is:
My Controller function is below:
public function Upload files($data='')
{
ini_set("display_errors",1); // I added so it would help me show errors
error_reporting(E_ALL);
print_r($_POST);exit('I am in the tp');
$config['upload_path'] = 'assets/images/uploads/';
//$config['allowed_types'] = 'gif|jpg|png';
//$config['max_size'] = 100;
//$config['max_width'] = 1024;
//$config['max_height'] = 768;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);exit('The first loop');
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);exit();
$this->load->view('upload_success', $data);
}
}
And my view file:
<div id="Upload_div">
<?php //echo $error;?>
<form action="<?php echo site_url() ?>/Admin/Upload_files/" method="POST" enctype="multipart/form-data">
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="userfile"><br><br>
<input type="submit" name="submit" value="submit">
</form>
</div>
Can anyone help me figure out why post value is empty?
Thanks
$_POST does not contain any file data.
Remove the line
print_r($_POST);exit('I am in the tp');
And then tell us what happens.

prestashop 1.7 new module

I have a problem in prestashop 1.7, when I load the form.tpl in my module I can not do a setAction. What I need is that when I continue in the payment I open a new sale with a payment platform and in prestashop in platform carge the validation I leave the code. help please
main file of the prestashop module
public function hookPaymentOptions($params) {
if (!$this->active) {
return;
}
$this->smarty->assign(
$this->getPaymentApiVars()
);
$apiPayement = new PaymentOption();
$apiPayement->setModuleName($this->name)
->setLogo($this->context->link->getBaseLink().'/modules/hhpayment/views/img/pago.jpg')
// ->setCallToActionText($this->l(''))
//Définition d'un formulaire personnalisé
->setForm($this->fetch('module:hhpayment/views/templates/hook/payment_api_form.tpl'))
->setAdditionalInformation($this->fetch('module:hhpayment/views/templates/hook/displayPaymentApi.tpl'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true));
return [$apiPayement];
}
this is the form.tpl that I charge this without the method but it is by tests
<form action="{$payment_url}" target="_blank" >
<div class="form-group">
{* choix du mode de carte *}
{l s='please choose your card type' mod='hhpayment'}
<div class="radio">
<label>
<input type="radio" name="cb_type" value="mastercard" id="cb_type1" checked="checked" /> Pago internacional
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="cb_type" id="cb_type2" value="visa"/> Pago Nacional
</label>
</div>
</div>
{* Informations pour l'api *}
<input type="hidden" name="success_url" value="{$success_url}" />
<input type="hidden" name="error_url" value="{$error_url}" />
<input type="hidden" name="id_cart" value="{$id_cart}" />
<input type="hidden" name="cart_total" value="{$cart_total}" />
<input type="hidden" name="id_customer" value="{$id_customer}" />
</form>
and this is the validation file
class hhpaymentvalidationModuleFrontController extends ModuleFrontController
{
/**
* Validation du paiement standard
* Puis redirection vers la page de succès de commande
*/
public function postProcess()
{
$cart = $this->context->cart;
$this->abrir("http://davivienda.com");
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
//La command passe directement en statut payé
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
}
public function abrir($param)
{
echo" <script> window.open(URL,'ventana1,'width=300,height=300,scrollbars=NO')</script> ";
}
}
I was able to find a solution to this problem, I don't know if it is the correct one, but it already works for me:
The postProcess method passes it to the main and the validation.php file passes it to the same folder where the main file is.
Then it is time to modify the validation.php file which was changed to the same directory as main, this file should be as follows.
It should be imported
require_once dirname(__FILE__) . '/config/config.inc.php';
require_once dirname(__FILE__) . '/main.php';
Then to avoid a kernel error the following code snippet must be implemented
global $kernel;
if(!$kernel){
require_once _PS_ROOT_DIR_.'/app/AppKernel.php';
$kernel = new \AppKernel('prod', false);
$kernel->boot();
}
After this, it is necessary to implement the logic and receive the parameters by get that the payment screen will return to us after the payment is made, once this data is received, the cart must be recovered and the data sent to the function that was migrated to the main file
ob_start();
$context = Context::getContext();
if (is_null($context->cart)) {
$context->cart = new Cart($context->cookie->id_cart);
}
if (is_null($context->cart->id_currency)) {
$context->cart->id_currency = $context->cookie->id_currency;
}
$cart = $context->cart;
$customer = new Customer($cart->id_customer);
$currency = $cart->id_currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$object = new filemain();
$order = $object->methodCreateInMain($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $currency, $customer->secure_key);
Basically the previous code in validation.php retrieves the cart data and sends it by parameter to the function that was passed to main, where the order will be validated and created.
It should be noted that the return url after payment must be ulrCommerce/module/validation.php
The above worked perfectly for me and is a solution based on various blogs and forums viewed

Method not receiving attributes from shortcode call, general OOP problems

The method OpenMods that you see below, is supposed to take an array generated by an fgetcsv function, and put it into an HTML table. __construct is supposed to, as is typically the case, define the attributes for the class, and shortcode is supposed to take two attributes from the shortcode, and if mods comes back, it is supposed to call another function in the class.
OpenMods did function when it was outside of a class, without the class attribute calls, so I'm fairly certain that isn't the source of my problem. My problem most likely lies within __construct and shortcode; However please don't overlook OpenMods as it may contain errors that are contributing to the problem, I'm just giving my estimation which isn't worth much since I'm having to ask to for help.
This is an example of the shortcode I'm trying to make work:
[priceguide file=’test.csv’ type=’mods’]
class CsvImporter
{
private $parse_header;
private $header;
private $delimiter;
private $length;
//--------------------------------------------------------------------
function __construct($parse_header=false, $delimiter="\t", $length=8000)
{
add_shortcode( 'priceguide', array( $this, 'shortcode' ) );
$this->parse_header = $parse_header;
$this->delimiter = $delimiter;
$this->length = $length;
}
//--------------------------------------------------------------------
public function shortcode($atts) {
$attributes = extract( shortcode_atts( array(
'file' => '',
'type' => '',
), $atts ));
if ($attributes['mods'])
{
$this->OpenMods($attributes['file']);
}
}
//--------------------------------------------------------------------
function OpenMods($file) {
ob_start();
$fp = fopen(plugin_dir_path( __FILE__ ) . $file , "r" );
if ($this->parse_header)
{
$header = fgetcsv($fp, $this->length, $this->delimiter);
}
// table header and search html
echo('<input type="text" class="search" id="search" placeholder="Search">');
echo('<br>');
echo('<table id="table"> <tr class="hidden">
<th><b>
Name</b>
</th>
<th><b>
Cheese</b>
</th>
<th><b>
Price</b>
</th>
<th><b>Vote</b>
</th>
</tr>
<tbody>');
// integer for drop down/price submit
$a = 1;
// set values for table data
while ($header !== FALSE) {
$name = $header[0];
$quanid = $header[2];
$table = $header[3];
unset($header[2]);
unset($header[3]);
$cssId = 'row-'.$a;
$a++;
//generate HTML
echo('<tr>');
foreach ($header as $index=>$val) {
echo('<td>');
echo htmlentities($val, ENT_QUOTES);
echo('</td>');
}
// query to get item prices
$sql = "SELECT ItemID, Price
FROM {$table}
WHERE ItemID = %d
GROUP BY Price
ORDER BY COUNT(*) DESC LIMIT 1";
global $wpdb;
$results = $wpdb->get_var( $wpdb->prepare( $sql, $quanid));
// put the results in the table
echo('<td>');
print_r($results);
echo('</td>');
// HTML for hidden row/price submission
echo('<td>
<button class="toggler" data-prod-cat="' . $cssId . '">Vote</button>
</td>');
echo('</tr>');
echo('<tr class="cat' . $cssId . ' hidden" style="display:none">');
echo('<td colspan="4" style="white-space: nowrap">Enter ' . $name . ' Price:
<form action="" name="form' . $quanid . '" method="post"><input type="text" id="' . $quanid . '" maxlength="4" name="' . $quanid . '" value="price_input" class="input" />
<button id="submit" name="submit" class="submit" type="submit" value="Submit">Submit</button></form>
<?php
?>
</td>
</tr>');
wp_nonce_field('price_input');
}
echo("</table>");
fclose($fp);
return ob_get_clean();
}
}
Based on OP comment, the problem is, the object can not created and in this case, __constructor() will not run, and add_shortcode( 'priceguide', array( $this, 'shortcode' ) ); will never triggered.
There are two solutions. One, if you are make the shortcode method to static, and add this in your functions.php file:
add_shortcode( 'priceguide', 'CsvImporter::shortcode' ) );
The second option, if you do not want to make it static if you instantiate an object from your class, before anythings happens. In your functions.php
add_action('init', 'my_init');
global $CsvImporter;
function my_init() {
global $CsvImporter;
$CsvImporter = new CsvImporter();
}
In this case, when no output send to the buffer, you create a new CsvImporter object, so the __construct() will run, so shortcode will registered.

Joomla 3.3 MVC file/pdf upload in custom component backend

I want to upload a pdf from a custom component from backend in the edit mode.
the state now is,
1.- either the pdf is uploaded correctly but the file name is not written in the database,
2.- or the file name is written in the data base, but the pdf is not seen by JFactory::getApplication()->input;
I found out is has with enctype="multipart/form-data" to do.
In case 1.- enctype="multipart/form-data" is in and the pdf is uploaded
in case 2.- the pdf file name is written in the data base.
What to do know ? I need both, of course.
Here so code, it is a little component com_job with MVC structure under Joomla! 3.3:
here just the part file administrator/components/com_job/views/tmpl/edit.php
with the enctype="multipart/form-data"
<form method="post" action="<?php echo JRoute::_('index.php?option=com_job&layout=edit&id='.(int) $this->item->id); ?>" id="adminForm" name="adminForm" enctype="multipart/form-data">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('title'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('title'); ?>
</div>
</div>
....
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('upload_pdf'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('upload_pdf'); ?>
</div>
</div>
........
here a part of the xml file administrator/components/com_job/models/forms/job.xml
<?xml version="1.0" encoding="utf-8"?>
...
<field
id="title"
name="title"
type="text"
required="true"
label="Title"
description="title_Desc"
class="inputbox"
size="40"/>
<field
id="upload_pdf"
name="upload_pdf"
type="file"
required="false"
label="Upload_pdf"
description="upload_pdf_Desc"
class="inputbox"
size="40"
accept="application/pdf"/>
.....
here the controller administrator/components/com_job/controllers/job.php
jimport('joomla.application.component.controlleradmin');
jimport('joomla.application.component.controllerform');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
class JobControllerJob extends JControllerForm
{
public function save()
{
$jinput = JFactory::getApplication()->input;
$files = $jinput->files->get('jform', null);
$files['upload_pdf']['name'] = JFile::makeSafe($files['upload_pdf']['name']);
if (!empty($files['upload_pdf']['name'])) {
$pdf_path = JPATH_ROOT . '/images/upload_pdf';
if (!JFolder::exists($pdf_path)) {
$status = JFolder::create($pdf_path);
if (!$status) {
JError::raiseWarning(100, JText::_('could not create directory pdf'), '');
}
}
$file_path = JPath::clean($pdf_path . '/' . strtolower($files['upload_pdf']['name']));
$status = JFile::upload($files['upload_pdf']['tmp_name'], $file_path);
if (!$status) {
JError::raiseWarning(100, JText::_('could not copy pdf'), '');
}
}
return parent::save();
}
}
where is the error ? I tried to put enctype="multipart/form-data" in the form in job.xml (models), but it didn't work.
I found a temporally solution, in the save function in the controller, I add this code:
//$jform = $jinput->get(jform, null);
$pdf_filename = JFile::makeSafe($files['upload_pdf']['name']);
$jform = $_POST['jform'];
$tmp_pdf_filename = array('upload_pdf' => $pdf_filename);
$merged_jform = array_merge($jform,$tmp_pdf_filename);
$jinput->post->set('jform',$merged_jform);
the first line with $jinput didn't work. I tried many ways with $jinput, but nothing worked. So finally I used directly $_POST. Of course, it is not the right way, but at least it works.
here the full function save:
public function save()
{
$jinput = JFactory::getApplication()->input;
$files = $jinput->files->get('jform', null);
$pdf_filename = JFile::makeSafe($files['upload_pdf']['name']);
if (!empty($pdf_filename)) {
$pdf_path = JPATH_ROOT . '/images/upload_pdf';
if (!JFolder::exists($pdf_path)) {
$status = JFolder::create($pdf_path);
if (!$status) {
JError::raiseWarning(100, JText::_('could not create directory pdf'), '');
}
}
$file_path = JPath::clean($pdf_path . '/' . strtolower($files['upload_pdf']['name']));
$status = JFile::upload($files['upload_pdf']['tmp_name'], $file_path);
if ($status) {
//$jform = $jinput->get(jform, null);
$jform = $_POST['jform'];
$tmp_pdf_filename = array('upload_pdf' => $pdf_filename);
$merged_jform = array_merge($jform,$tmp_pdf_filename);
$jinput->post->set('jform',$merged_jform);
} else {
JError::raiseWarning(100, JText::_('could not copy pdf'), '');
}
}
return parent::save();
}
$jinput = JFactory::getApplication()->input;
$files = $jinput->files->get('jform');
$file = $files['upload_pdf'];
Try this...it is true method!!!
That should do the trick. The $file array then holds the following keys:
error
name
size
tmp_name
type