1. Please add file upload element to the first page of your form.
2. Click it to see its properties. Enter ins name = file_upload
3. Select Tools -> PHP Editor and find $form->doAfterSubmitAction(); line there
4. Insert the following after this line:
- Code: Select all
if ($form->page == 1 && isset($form->files['file_upload'])) {
$errors = array();
if (filesize($form->files['file_upload']['tmp_name']) > 2 * 1024 * 1024) {
$errors[] = 'The file size must be less than 2 Mb.';
}
$allowedExtensitons = array('zip', 'jpg', 'tar');
$fileExtension = pathinfo($form->files['file_upload']['name'], PATHINFO_EXTENSION);
if (!in_array($fileExtension, $allowedExtensitons)) {
$errors[] = 'The file extension is not allowed';
}
if (count($errors) > 0) {
$form->error .= implode('<br/>', $errors);
$form->page = 0;
}
}
N.B. $allowedExtensitons = array('zip', 'jpg', 'tar'); line contains the allowed extensions. Please enter the ones you need there.
5. Save the changes in the editor and close it. Save the form

