This topic is locked

Custom Expression under view as->File

5/29/2020 2:56:25 PM
PHPRunner General questions
B
bgohio_GIS author

So under the Fields tab, I select the LetterFile properties and go to view as select file and then check Show Custom Expression and enter:
$value = 'Download';

$file['usrName']= $data['LetterFile'];

$file['size']= filesize($data['LetterFile']);

$file['type']= mime_content_type ($data['LetterFile']);
To clarify things, $data should contain all columns from my sql table I'm referencing which makes LetterFile valid. LetterFile is the column name that stores the UNC path(with filename) as nvarchar.
But when I build the page out it displays a blank for the file. Not much else in the documentation to go by what am I missing?
I have already confirmed my web server has the proper access and can read/write to the directory LetterFile is refferencing.

Sergey Kornilov admin 5/29/2020

If this your complete code? $file array is not defined and is not being used so this code alone doesn't make much sense.
Also, what specific page in the documentation you referring to? filesize() and mime_content_type() are PHP functions, not PHPRunner's.

B
bgohio_GIS author 6/1/2020



If this your complete code? $file array is not defined and is not being used so this code alone doesn't make much sense.
Also, what specific page in the documentation you referring to? filesize() and mime_content_type() are PHP functions, not PHPRunner's.


See Image
Maybe this will clear things up

M
MikeT 6/2/2020

The custom expression for view as file expects the meta info of the file to be stored in a json array, see here: https://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm

If you use the phpr built in way to store files (as text, not binary), the application will create these json arrays automatically after upload.
In the dialog you reference you just pull info from the record ($data) and/or the json and rearrange them in the desired way that you want to be used (see examples in the referenced help article above). You don't set database values here, it's for "how to display the data in the database".
If you're running your own system on how to store filenames, paths etc, you'd have to custom code everything.