首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加上载/处理状态栏/throbber

添加上载/处理状态栏/throbber
EN

Drupal用户
提问于 2020-07-04 00:30:22
回答 1查看 68关注 0票数 0

我是Drupal/web开发的新手,我一直在尝试创建一个模块来添加文件上传菜单。一旦上传了文件,就会进行处理,并在完成处理后显示一条消息。一切运行良好,但我想添加一个处理进度栏/从瓷砖提交按钮被选中时,最后的输出显示。我对如何实现这一点一无所知。任何帮助都是非常感谢的。

下面是我使用的代码的一部分:

代码语言:javascript
复制
//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 
 "),
        "#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);
}

从代码中可以看到,我在上传时处理文件,并在处理后显示输出消息。我想添加一个throbber/processing-从提交时间选择到输出显示时间的进度条,在文件被处理之后。我怎样才能做到这一点?再次,请理解,我是新的网页开发/Drupal,并没有非常熟练的术语/命令在他们使用。

EN

回答 1

Drupal用户

发布于 2020-07-05 14:35:57

将文件更改为manager_file并使用属性#progress_indicator (默认情况下已经设置好了,因此不必添加它)。

https://api.drupal.org/api/drupal/developer%21topics%21forms_api接口_Cence.html/7.x#托管_文件

票数 0
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/295052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档