On a Form there is a file object:
ID: file_test
Input Type: File
Then I'd like to process a selected file with PHP code in the "After Save" event (to save it to the file system and also send it as attachment by email)
Unfortunately, I don't manage to get a reference to that file object so I can process it further.
First attempt:
Code: Select all
$F = "#file_test#";
nuDebug("F: ".$F); // <--- variable is empty
Code: Select all
$F = nuHash()['file_test'];
nuDebug("F: ".$F); // <--- variable is empty
Code: Select all
$J = json_decode($F);
nuDebug("J".$J);
$name = $J[0]->{'name'};
$type = $J[0]->{'type'};
$file = $J[0]->{'file'};
nuDebug("name: ".$name );
nuDebug("type: ".$type );
nuDebug("file: ".$file );
$contents = file_get_contents(sys_get_temp_dir().$name); //obtain the contents of the file
$contents = addslashes($contents);
nuDebug("contents: ".$contents );
// and more to do...
$filelist = array();
array_push($filelist, ......);
nuSendEmail(....);
If possible, I don't want to save the file data (as JSON) in a field nor in the db.