Possible Duplicate:
“On file dialog cancel” event in JavaScript
Is there a listener for when a user clicks cancel instead of done on a file upload dialog box?
Possible Duplicate:
“On file dialog cancel” event in JavaScript
Is there a listener for when a user clicks cancel instead of done on a file upload dialog box?
No, there isn't a way to determine if the user clicked "Cancel" using the input="file" html element.
If you need more control over the file upload on a webpage, you can use Flash like Gmail does.
No, but you can check if the value has changed (e.g. the user picked a file) using a listener for the change
event.
Simple example:
HTML:
<input id=f type=file>
JavaScript:
function picked(){
alert("Picked");
}
$('#f').focus(function(evt){
$(this).change(picked);
});
他の人が述べているように、入力アップロードタグはこれを行うことができません。
私はこのサードパーティのJSアップローダーを使用して良い経験をしました。Flashを使用しないため、モバイルデバイスにも適しています。
次の設定を行うことができます。
onCancel: function(id, fileName){}
初期設定呼び出しで。詳細については、Githubページの手順を参照してください。
Most likely it depends on the browser. Some browsers might allow you catch this. Other browsers might not. This is because HTML standard does not explicitly state how a file upload control should look like or how the file selection has to be implemented. It just says that:
This control type allows the user to select files so that their contents may be submitted with a form. The INPUT element is used to create a file select control.
Browser developers may choose how they allow you to select files. It may be a pop-up window, it may as well be a list of all files in your computer/device which you have to pick from.
HTML5 defines the behavior a little better, but again it does not talk about file selection process.