Hello!

My form has a file field (Field Key: 'fileforupload').
Could anyone advise me how can I get access to the name (or path) of selected file in Additional Validation area?

The following code $form_values['submitted_tree']['fileforupload'] returns Array. And I don't know how to access the elements of this array.

Thank you in advance.

Comments

quicksketch’s picture

The following code $form_values['submitted_tree']['fileforupload'] returns Array.

I'd suggest installing the devel.module and using the dsm() function to look at the contents of the $form_values array. The file path should be in $form_values['submitted_tree']['fileforupload']['filepath'].

quicksketch’s picture

Title: File field validation » File field path validation
Category: task » support
djandrey’s picture

The array $form_values['submitted_tree']['fileforupload'] consists of one element only - ['new'], and code form_set_error('submitted][fileforupload', $form_values['submitted_tree']['fileforupload']['new']) always returns 'fileforupload' in spite of whether the file was selected or not. So your construction $form_values['submitted_tree']['fileforupload']['filepath'] doesn't work.

By the way, I've installed devel.module. Undoubtedly, this is a very useful module for the developers but number of elements of my array hasn't increased :)

Any ideas?

quicksketch’s picture

Status: Active » Closed (fixed)

Help with custom coding is not provided in the Webform issue queue.