Retrieving File Upload path and file name

batvink 29 Feb, 2016
I want to find an uploaded file so I can open and process it. I can see this with the debugger...

Array
(
    [csvFile] => Array
        (
            [name] => 20160229213250_test.csv
            [original_name] => test.csv
            [path] => /home/xxxxxxx/xxxxxx/xxxx/components/com_chronoforms5/chronoforms/uploads/BasicUpload/20160229213250_test.csv
            [size] => 3593
            [link] => http://xxxx.xxxxxx.co.uk/components/com_chronoforms5/chronoforms/uploads/BasicUpload/20160229213250_test.csv
        )

)


I tried to get the path using the following PHP:

<?PHP
$myFile = $form->data['csvFile']['path'];
echo("My PATH = " . $myFile);
?>


This produces the following error:

Warning: Illegal string offset 'path' in.....custom_code.php


And My Path prints the value 2 (the index of the value in the array, I presume.

Thanks in advance for any help.
GreyHead 29 Feb, 2016
Hi batvink,

The file name will be in $form->data['csvFile'], the link, path,, etc are in $form->files['csvFile'] so
<?php
echo "My PATH = {$form->files['csvFile']['path']}";
?>

Bob
batvink 01 Mar, 2016
Perfect, thanks!

I'm not sure how I could work that out myself from the debug data, but I'm just happy that it works.

Steve V.
This topic is locked and no more replies can be posted.