This topic is locked
[SOLVED]

 Uploading File to custom directory

4/2/2020 8:14:43 AM
PHPRunner General questions
need2sleep authorDevClub member

I'm using the following code in PHP expression:

$folder = "files/clients/".$data['clientid'];


but it doesn't seem to find the Client ID and uploads only into the "clients" directory.
Any advice on how to pull the current clientid variable from the database?
Thanks,

Sergey Kornilov admin 4/2/2020

You cannot $data['clientid'] or anything like this. Files are uploaded before the record is created so on the Add page we won't know what field hold which value.
Please refer to the documentation that explains what you can use there:

https://xlinesoft.com/phprunner/docs/edit_as_settings_file_image.htm

need2sleep authorDevClub member 4/2/2020

That totally makes sense. I guess I was thinking in the edit section when the clientid is already created.

Sergey Kornilov admin 4/2/2020

This can be done. You can use an event like ProcessRecordValues of the Edit page to save clientid to some session variable and then use this session variable in the custom folder expression.

need2sleep authorDevClub member 4/2/2020

Wonderful thank you. I should have started in the edit section first.

$_SESSION["UpFolder"] ="files/client/".$values['clientid']."/";