This topic is locked
[SOLVED]

  file upload

10/22/2012 8:56:13 AM
PHPRunner General questions
author

Hi
I am using PHPrunner 6.2 and am using the new upload feature (which is very good). I used to run an event that took the file names to a session variable so I could run my own scripts.
The cell data looks as follows

[{"name":"custom_upload\/files\/BlueStar - BCC LLC - September_2012_2855052_bettercostcontrol-20121018-204156_fbmak912.xls","usrName":"BlueStar - BCC LLC - September_2012_2855052_bettercostcontrol-20121018-204156.xls","size":48128,"type":"application\/vnd.ms-excel","searchStr":"BlueStar - BCC LLC - September_2012_2855052_bettercostcontrol-20121018-204156.xls,!:sStrEnd"}]
How can i get the file name. i.e i used to do $_SESSION["file"] = $values["file"]; i just need the upload file name, not the rest of the code.
Thanks in advance

Sergey Kornilov admin 10/22/2012

Your old won't work here because you now have multiple files and cannot store them in the single session variable.
The format in question is JSON and you can convert this string to a regular PHP array the following way:

$filesArray = my_json_decode($value);


name contains the path to your file, usrName contains just the file name.

7542 10/23/2012

Hi, Thanks

I did this:
$file = $data_upload_files["upload"];

$filesArray = my_json_decode($file); //convert my_sdon to array

$uploadfile =$filesArray['usrName'];
echo $uploadfile; // test ouutput
and the query returned empty. This is the contents of the array cell that also prints on screen with echo $file;
ps. also tried this // $uploadfile =$filesArray->{'usrName'}; // tried this as a web forum recommended it
Thanks for your help
Richard

7542 10/23/2012

Hi All
This code worked
$file = $data_upload_files["upload"];

$filesArray = json_decode($file);

echo $filesArray[0]->usrName;
Thanks for your help Sergey