调用未定义的函数curl_file_create()[文件处理] [英] Call to undefined function curl_file_create() [file handling]
问题描述
我正在尝试上传带有curl的文件,并且在PHP文档中说:
I'm trying to upload a file with curl, and in the PHP documentation it says:
要发布文件,请在文件名前添加@并使用完整路径.可以通过在文件名后跟随类型为'; type = mimetype'的类型来明确指定文件类型.该参数可以作为urlencoded字符串(如"para1 = val1& para2 = val2& ...")传递,也可以作为字段名称作为键并将字段数据作为值的数组传递.如果value是一个数组,则Content-Type标头将设置为multipart/form-data.从PHP 5.2.0开始,如果使用@前缀将文件传递给此选项,则value必须是一个数组.从PHP 5.5.0开始,不赞成使用@前缀,并且可以使用CURLFile发送文件.
To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'. This parameter can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile.
所以我尝试改用CURLFile,但是出现错误
So I try using CURLFile instead, whereas I get the error
调用未定义函数curl_file_create()
Call to undefined function curl_file_create()
所以-然后我尝试使用以下命令找到类CURLFile var_dump(class_exists('curlfile'));
so - then I try to locate the class CURLFile with
var_dump(class_exists('curlfile'));
但是它表示没有.我想知道-CURLFile是否必须手动安装?而且,即使很快就会弃用@ path/to/file; type = mime还是更好?
But it says that it doesn't. I wonder - is CURLFile something one has to install manually? And is it better to use the @path/to/file;type=mime instead, even though it will be deprecated soon enough?
谢谢
笨拙-已安装curl并起作用.只是我的系统上似乎不存在文件处理Mumbo jumbo.
To clairy - curl is installed and works. It's only the file-handling mumbo jumbo that doesn't seem to exist on my system.
我没有添加任何代码,因为没有要添加的代码.我运行 curl_file_create()
并获得了该函数不存在的答案,即使curl本身可以工作.
I don't add any code, cause there is no code to add.
I run curl_file_create()
and get the answer that the function doesn't exists, even though curl itself works.
推荐答案
我不使用"curl_file_create"和"CurlFile",我更喜欢使用"@/file_name_with_full_path".
I do not use "curl_file_create" and "CurlFile", I prefer to use "@/file_name_with_full_path".
请参阅参考链接,并使用其他方法通过PHP通过CURL通过POST方法上传文件.
See the reference links and use these other methods for file upload via POST method via CURL via PHP.
这篇关于调用未定义的函数curl_file_create()[文件处理]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!