$form['#attributes']['enctype'] = 'multipart/form-data'; $form['survey']['file-upload'] = array( '#type' => 'file', '#prefix' => '', '#suffix' => '', '#description' => 'Image type PNG/JPG Max Size:2Mb.', );
function create_survey_form_validate($form, &$form_state){ $save = file_save_upload('file-upload', array('file_validate_extensions' => array("jpg png")),"public://user_sheets",FILE_EXISTS_RENAME); if($save == null){ form_set_error('file_upload', 'Please select a file'); } else if($save == FALSE){ form_set_error('file_upload', 'Error in file upload'); } }
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['survey']['file-upload'] = array(
'#type' => 'file',
'#prefix' => '<div class="survey-file-upload">',
'#suffix' => '</div></div>',
'#description' => 'Image type PNG/JPG Max Size:2Mb.',
);
function create_survey_form_validate($form, &$form_state){
$save = file_save_upload('file-upload', array('file_validate_extensions' => array("jpg png")),"public://user_sheets",FILE_EXISTS_RENAME);
if($save == null){
form_set_error('file_upload', 'Please select a file');
}
else if($save == FALSE){
form_set_error('file_upload', 'Error in file upload');
}
}