I am new to Drupal/web development and I have been trying to create a module to add files upload menu. Once the files are uploaded, they undergo processing and a message is displayed upon completion of the process. Everything works well but I would like to add a processing progress bar/throbber from the tile Submit button is selected to when the final output is displayed. I am clueless on how to implement this. Any help is appreciated
Here's part of the code I used:
//Before this part of the code, there is function to create Menu ($items[])
function g_p_proc_form($form, &$form_state, $values) {
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['filter'] = array (
"#type" => "fieldset",
"#title" => t("File Process <BR> "),
"#collapsible" => TRUE,
);
// without this attribute, upload may fail on submit
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['filter']['file'] = array(
// '#title' => t('File processing'),
'#type' => 'file',
'#name' => 'files[]',
'#description' => t('Select Submit to start processing the file'),
'#type' => 'file'),
'#upload_location' => 'public://',
'#attributes' => array('multiple' => 'multiple'),
);
$form['filter']['submit_upload'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
// drupal_set_message(t("in fn"));
return $form;
}
function g_p_proc_form_submit($form, &$form_state) {
try{
$number_file = count($_FILES['files']['name']);
$f_name = array();
for ($i=0; $i<$number_file;$i++)
{
$file = file_save_upload($i, array('file_validate_extensions' => array('pdf PDF')), 'public://', FILE_EXISTS_REPLACE);
$f_name[] = $_FILES['files']['name'][$i]; //[]
}
}catch (Exception $error){
echo 'Exception: ', $error->getMessage(), "\n";
}
$n_f = count($f_name);
drupal_set_message(t('Number of files: !n_f', array('!number_f'=>$n_f)));
$fn_name = 'g_p';
$fn_call = $fn_name($f_name);
function g_p($f_name=array()){
$curr_l = getcwd();
chdir('My file processing PHP script location ');
$n_f = count($f_name);
$shell_command = shell_exec("file_processing_php_script_name.php");
//header("Location: "Current file processing module menu site"); //Commented out
drupal_set_message($shell_command);
chdir($curr_l);
}
As it can be seen from the code, I process the files upon upload and display the output message after processing. I would like to add a throbber/processing-progress bar from the time Submit is selected to the time the output is displayed, after the files are processed. How can I achieve this? Again, please understand that I am new to web development/Drupal and am not very proficient in terms/commands used in them.