Have a file input form upload when a user clicks “open”

后端 未结 2 1429
一生所求
一生所求 2021-01-17 05:39

I am wondering if this flow is possible:

  1. Click a button that says \"Upload\". It is styled very differently from the usual . It does not show the \"No file

2条回答
  •  日久生厌
    2021-01-17 06:01

    If you use a form submit, the file finished uploading when the (likely POST) request is complete.

    To trigger the submit when the input value change, use form.submit() in JavaScript.

    $('#file_input').change(function() {
        $(this).closest('form').submit();
    });
    

    Your server should send back the redirect as a response (e.g. status code 301, 302, 303, etc.).

提交回复
热议问题