Skip to content

Add file paths to form tokens - #437

Merged
Toflar merged 1 commit into
mainfrom
feature/file-paths
Apr 21, 2026
Merged

Add file paths to form tokens#437
Toflar merged 1 commit into
mainfrom
feature/file-paths

Conversation

@aschempp

Copy link
Copy Markdown
Member

In NC 1.x, if xxx was a file upload field, the form_xxx would contain the path to the uploaded file. In NC2 this now contains the voucher for bulky items storage.

This PR re-adds a simple token for the file path, because sometimes you don't want to send the file by email but store it on the server and get the path by email (e.g. for manual download, secure contract review etc.).

I have manually tested this and it seems to work flawlessly. If you do not check "Store files" in the form generator, the email will contain the temporary PHP path (which makes no sense but shouldn't harm).

@aschempp aschempp added this to the 2.7 milestone Apr 20, 2026
@aschempp
aschempp requested a review from Toflar April 20, 2026 06:51
@aschempp aschempp self-assigned this Apr 20, 2026
@Toflar

Toflar commented Apr 20, 2026

Copy link
Copy Markdown
Member

The reason why the bulky items storage exists is so that you can also re-send a file with attachments (whether that's an attachment or a download link via notification_center_file_url() in case of e.g. a temporary failure etc. for up to 7 days after submission (or whatever retention period is configured). Re-sending can be done comfortably using NC Pro.

Can you elaborate why you want to work with a temporary path that can be gone in a few hours rather than just linking to the bulky items storage item which is already implemented?

@aschempp

Copy link
Copy Markdown
Member Author

Because file uploads can be stored in the Contao files directory. In case of my client, they want the native path to a directory they can download from via FTP. Bulky items are nice for re-sending the file content again, but that's neither the requirement nor useful in my case.

@Toflar

Toflar commented Apr 20, 2026

Copy link
Copy Markdown
Member

So tmp_name in this case is not actually a temporary name but a path pointing to files/foobar/upload.pdf?

@aschempp

Copy link
Copy Markdown
Member Author

correct. The Contao file upload widget (and or fineuploader) actually replaces the tmp_path if the file is stored.

@Toflar

Toflar commented Apr 20, 2026

Copy link
Copy Markdown
Member

Kinda wonder if we can/should add some guard to only provide this info if it's an upload that's been moved to files. Because if it is a temporary upload, you should never work with the temporary path but the bulky item storage, imho. Wdyt?

@aschempp

Copy link
Copy Markdown
Member Author

I don't see the point. Its up to the user to correctly configure their form and notification, there's no point and no harm in sending a useless temporary path. I would not send the path to the bulky items storage because you don't want people to mess with that.

@Toflar
Toflar merged commit b799d09 into main Apr 21, 2026
30 checks passed
@Toflar
Toflar deleted the feature/file-paths branch April 21, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants