gpt4 book ai didi

php - 哪个 HTTP 状态代码应该用于 UPLOAD_ERR_PARTIAL?

转载 作者:可可西里 更新时间:2023-10-31 22:08:52 24 4
gpt4 key购买 nike

我正在开发一个 REST API 并且我有一些文件上传:

当文件只上传了一部分时,PHP 会产生一个 UPLOAD_ERR_PARTIAL 错误,我不确定是哪个 HTTP status code应该在这种情况下使用。

如果用户取消上传(参见 Why might a file only be partially uploadedfile upload errors on php.net),通常会发生这种情况

UPLOAD_ERR_PARTIAL is given when the mime boundary is not found after the file data. A possibly cause for this is that the upload was cancelled by the user (pressed ESC, etc).

最佳答案

对于这种情况,您应该使用 409 状态码。

根据 http://www.ietf.org/rfc/rfc2616.txt :

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where
it is expected that the user might be able to resolve the conflict
and resubmit the request. The response body SHOULD include enough
information for the user to recognize the source of the conflict.
Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be
possible and is not required.

关于php - 哪个 HTTP 状态代码应该用于 UPLOAD_ERR_PARTIAL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18232580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com