Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function crhubTestForm() {
- return drupal_get_form('crhub_crhubTestForm');
- }
- function crhub_crhubTestForm($form_state) {
- $form['upload_file'] = array(
- '#type' => 'file',
- '#title' => t('File to read')
- );
- //SUBMIT BUTTON
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' =>'Submit',
- );
- return $form;
- }
- function crhub_crhubTestForm_validate($form, &$form_state) {
- $filePath = $form_state['values']['upload_file'];
- dsm($form_state['values']);
- if ($filePath) {
- if (is_file($filePath)){
- form_set_error('upload_file', "Please enter a file name ");
- }
- }
- else {
- form_set_error('upload_file', "Please enter a file name:");
- }
- /*else {
- if (!is_file($filePath))
- form_set_error('upload_file', 'Please enter a valid file name.');
- *
- */
- }
- function crhub_crhubTestForm_submit($form, &$form_state) {
- drupal_set_message(t('The form has been submitted.'));
- dsm($form_state['values']);
- /*debug ($form, 'Form ', false); */
- $filePath = $form_state['values']['upload_file'];
- include_once ('CMatArticleHandler.inc');
- $Handler = new CMatArticleHandler($filePath, 'r');
- $Handler->runMain('1');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement