tobimori / kirby-dreamform

✨ DreamForm is an opiniated form builder plugin for Kirby CMS that makes forms work like magic
https://plugins.andkindness.com/dreamform
41 stars 5 forks source link

Ability to have links to files in mail #89

Open Matoseb opened 2 weeks ago

Matoseb commented 2 weeks ago

Hi, is there a way to have a link to the uploaded files in a mail template? A client wants to access the files directly from the mail without logging in to Kirby.

I can have the file names but the field value doesn't seem to have the url inside:


if($field::type() === "file-upload") {
  $fileArray = $field->value()->value();
  echo implode(", ", array_map(fn($file) => "{$file['name']}", $fileArray));
}
tobimori commented 2 weeks ago

You should be able to access the file object using the submision, something like $submission->valueForId($field->id())->toFile()

Matoseb commented 2 weeks ago

Ah it seems the file is in a temporary state

[{"name":"gradient_00.png","full_path":"gradient_00.png","type":"image\/png","tmp_name":"\/private\/var\/folders\/gw\/9s1_3_nn0r79dpqf536_zhk00000gn\/T\/phpBFZSjs","error":0,"size":894}]

I don't have access to the file yet, it gives me null

tobimori commented 2 weeks ago

You're right, the game only saves the file after actions have been sent, so it's not possible to get the file URL in the Email action.

tobimori commented 2 weeks ago

My suggestion would be to add an API route that uses the UUID of the submission and filename to find the file and return it.

Matoseb commented 2 weeks ago

100% agree, I will try this