Home  >  Article  >  Backend Development  >  接口-php CURLOPT_POSTFIELDS的绝对路径参数怎样填写?(因为图片上传得不到绝对路径)

接口-php CURLOPT_POSTFIELDS的绝对路径参数怎样填写?(因为图片上传得不到绝对路径)

WBOY
WBOYOriginal
2016-06-02 11:31:591193browse

接口php求救图片上传参数

利用微信的上传图片接口写一个php文件。

<code>HTML代码如下:<input type="file" name="file" value="123"><br><input type="submit" name="submit" value="submit"></code>

php代码:curl_setopt($ch, CURLOPT_POSTFIELDS, 第三个参数);
微信接口要求第三个参数是个media=@绝对路径。
但是上网找了很多资料,似乎无法获得用户上传的图片的绝对路径,求教各位大神,这个问题怎么解决?

ps:本人也找过一些教程,说第三个参数可以为 dirname(__FILE__)."图片名",
dirname得到的是服务器的php文件的目录路径吧?但是假如我的php文件放在/usr/php/里,岂不是要求用户上传的图片也放在他们电脑的/usr/php/里?这个是怎么回事?求教求救,各位大神帮帮我

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn