文件上传角度

时间:2019-07-17 14:33:17

标签: javascript html

选择文件后,文件名未显示在标签中。

def start_machines():

    with open('/home/ec2-user/object_list', 'r') as f:
        objects = f.readlines()

    with concurrent.futures.ThreadPoolExecutor(max_workers=30) as executor:

        future_to_object = {executor.submit(do_object_processing, obj): obj for obj in objects}
        for future in concurrent.futures.as_completed(future_to_object):
            result = future_to_object[future]
            try:
                data = future.result()
            except:
                print('oops')

2 个答案:

答案 0 :(得分:0)

上面的代码工作文件请参见下文

 <div class="custom-file">
      <input type="file" class="custom-file-input"
          aria-describedby="txtFileUpload" accept=".csv">
      <label class="custom-file-label" id="txtFileUpload" >Choose file</label>
  </div>

答案 1 :(得分:0)

您的自定义class="custom-file-input"是一个引导类,您需要提供必要的脚本来处理文件并显示名称:

  $(".custom-file-input").on("change", function() {
  var fileName = $(this).val().split("\\").pop();
  $(this).siblings(".custom-file-label").addClass("selected").html(fileName);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="custom-file">
    <input type="file" class="custom-file-input" id="customFile">
    <label class="custom-file-label" for="customFile">Choose file</label>
  </div>

来源:https://www.w3schools.com/bootstrap4/bootstrap_forms_custom.asp