文件输入:在提交表单之前,Chrome不会检查文件是否仍然存在

我最近发现了一个错误,导致我的服务器在文件上传期间崩溃。

I recently found a bug that made my server crash during a file upload.

当用户点击文件输入时,选择要上传的文件。如果用户在提交表单之前删除或重命名该文件,Chrome仍会发送一个空文件。 (虽然firefox和IE正确处理错误)

When the user clicks on a file input, and chooses a file to upload. If the user deletes or renames the file before submitting the form, Chrome still sends an empty file. (while firefox and IE handle the error correctly)

用户点击提交按钮后,我试图检查文件大小,但它是不为空。

After the user has clicked on the "submit" button, I've tryed to check the file size, but it is not null.

        if (file.size == 0) {
            NotificationFactory.AlertMessage({ messageType: "error", message: "File is missing" });
        }

我已经处理了错误服务器端,但想添加一些验证客户端。

I've already handled the error server-side, but would like to add some validation client-side.



 1 条回答