更新时间:2022-10-18 19:28:10
,当(可能的POST)请求完成时,文件完成上传。
要在输入值更改时触发提交,请使用 form.submit ()
in JavaScript。
$('#file_input')。
$(this).closest('form')。submit();
});
您的服务器应该发送重定向作为响应(例如状态码301,302,303等。)。
I am wondering if this flow is possible:
Click a button that says "Upload". It is styled very differently from the usual . It does not show the "No file selected" text.
The usual file browser pops open. The user chooses a file to upload. They click the "open" button in the file browser.
Upon clicking "open", the file browser is closed (like normal) and the file immediately begins uploading (unlike normal where it requires a submit).
I detect when the file is finished uploading, and direct to another page.
Here is how I would try to implement it:
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.).