gradio/demo/file_component_events/run.py
Dawood Khan 3f139c7c99
Fix File drag and drop for specific file_types (#6982)
* fix file drag

* add changeset

* pr fixes

* test

* add changeset

* tests

* fix

* type fix

* add changeset

* functional test fix

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
2024-01-17 18:12:15 -05:00

22 lines
1.0 KiB
Python

import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
file_component = gr.File(label="Upload Single File", file_count="single")
with gr.Column():
output_file_1 = gr.File(label="Upload Single File Output", file_count="single")
num_load_btn_1 = gr.Number(label="# Load Upload Single File", value=0)
file_component.upload(lambda s,n: (s, n + 1), [file_component, num_load_btn_1], [output_file_1, num_load_btn_1])
with gr.Row():
with gr.Column():
file_component_multiple = gr.File(label="Upload Multiple Files", file_count="multiple")
with gr.Column():
output_file_2 = gr.File(label="Upload Multiple Files Output", file_count="multiple")
num_load_btn_2 = gr.Number(label="# Load Upload Multiple Files", value=0)
file_component_multiple.upload(lambda s,n: (s, n + 1), [file_component_multiple, num_load_btn_2], [output_file_2, num_load_btn_2])
if __name__ == "__main__":
demo.launch()