简体   繁体   English

PHP使用exec运行curl

[英]PHP run curl using exec

I tried running a curl command in php using exec method, it worked well in my Linux server, but not working in my Windows machine, I checked my PHP configuration file too, curl is enabled there. 我尝试使用exec方法在php中运行curl命令,该命令在我的Linux服务器上运行良好,但在Windows机器上却不工作,我也检查了我的PHP配置文件,在那里启用了curl。 What could be the issue that it is not working ? 它不起作用可能是什么问题?

My command is (one used for Linux - this one ran succesfully there) 'curl -u admin:geoserver -XPUT -H "Content-type:image/tiff" --data-binary @/opt/lampp/htdocs/PDAN_Dev/Admin/uploads/tif/'.$data_set_name.'.tif http://localhost:8080/geoedge/rest/workspaces/geoedge/coveragestores/ '.$data_set_name.'/file.geotiff' 我的命令是(一个用于Linux的命令-这个命令已经成功运行了)'curl -u admin:geoserver -XPUT -H“ Content-type:image / tiff” --data-binary @ / opt / lampp / htdocs / PDAN_Dev /管理员/上传/tif/'.$data_set_name.'.tif http:// localhost:8080 / geoedge / rest / workspaces / geoedge / coveragestores /'.$ data_set_name。'/ file.geotiff'

The one I ran in Windows 我在Windows中运行的那个

exec("curl -u admin:geoserver -XPUT -H Content-type:image/tiff --data-binary C:/Users/Developer/Desktop/geoedge-test12.tif http://107.167.186.125:8080/geoedge/rest/workspaces/geoedge/coverageStores/geoedge-test13/file.geotiff ") exec(“ curl -u admin:geoserver -XPUT -H内容类型:image / tiff --data-binary C:/Users/Developer/Desktop/geoedge-test12.tif http://107.167.186.125:8080/geoedge /rest/workspaces/geoedge/coverageStores/geoedge-test13/file.geotiff “)

When I ran it in the command prompt it gives me no output 当我在命令提示符下运行它时,没有任何输出

It means that you have not installed curl on your windows machine. 这意味着您尚未在Windows计算机上安装curl。 PHP curl is not same thing as machine installed curl. PHP curl与机器安装的curl不同。 When you are checking php configuration, it shows modules installed for php, not for machine. 当您检查php配置时,它显示的是为php安装的模块,而不是为计算机安装的模块。

You shouldn't run curl using the exec function, but with the build in php functions . 您不应该使用exec函数运行curl,而应该使用php函数中构建

It's not because the php curl extension is installled that this library is installed globaly on your windows machine. 并不是因为已安装php curl扩展程序,所以此库已全局安装在Windows计算机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM