且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 PHP 5.5 升级到 5.6 后,cURL 文件上传不再起作用

更新时间:2023-02-22 19:49:05

其实我在开始提问的时候就找到了答案.PHP 5.5 中的 curl 包含一个新变量:CURLOPT_SAFE_UPLOAD 在 PHP 5.5 中默认设置为 false 并切换为默认值 true代码>在 PHP 5.6 中.

Actually I found the answer while starting the question. There is a new Variable included with curl in PHP 5.5: CURLOPT_SAFE_UPLOAD this is set to false by default in PHP 5.5 and is switched to a default of true in PHP 5.6.

出于安全原因,这将阻止@"上传修饰符工作 - 用户输入可能包含恶意上传请求.您可以使用 CURLFile 类上传文件,而 CURLOPT_SAFE_UPLOAD 设置为 true 或(如果您确定您的变量是安全的,您可以切换手动将 CURLOPT_SAFE_UPLOAD 改为 false):

This will prevent the '@' upload modifier from working for security reasons - user input could contain malicious upload requests. You can use the CURLFile class to upload files while CURLOPT_SAFE_UPLOAD is set to true or (if you're sure your variables are safe you can switch the CURLOPT_SAFE_UPLOAD to false manually):

 curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);

以下是让我朝着正确方向搜索的信息来源:http://comments.gmane.org/gmane.comp.php.devel/87521

Here's a source for the information that got me searching in the right direction: http://comments.gmane.org/gmane.comp.php.devel/87521

在更改的函数中也提到了:http://php.net/manual/en/migration56.changed-functions.php但不是在向后不兼容的变化中,真的把我绊倒了......

It's mentioned in the changed functions too: http://php.net/manual/en/migration56.changed-functions.php But not in the backward incompatible changes, really tripped me off...