Home  >  Article  >  Backend Development  >  file_put_contents 保存图片路径怎么设置?

file_put_contents 保存图片路径怎么设置?

WBOY
WBOYOriginal
2016-06-23 13:09:263117browse

file_put_contents 保存图片路径怎么设置?
我代码 $img_size = file_put_contents("D://www/web/public/". $pic_name, $img_data);
他提示:Warning: file_put_contents(D://www/web/public/gs_237f015b.gif): failed to open stream: No such file or directory 
public这个文件夹存在的


回复讨论(解决方案)

$img_size = file_put_contents("D:/www/web/public/". $pic_name, $img_data);

$img_size = file_put_contents("D:/www/web/public/". $pic_name, $img_data);


这样写不行呀,提示Warning: file_put_contents(D://www/web/public/gs_237f015b.gif): failed to open stream: No such file or directory

D://www/web/public
仔细检查一下这个目录存在吗

D://www/web/public
仔细检查一下这个目录存在吗


确定存在,换了好几个目录了,都不行

你的系统是? 
现在的代码是?

你的系统是? 
现在的代码是?


系统是windows,代码就是你写的代码,如果换成$img_size = file_put_contents(" ". $pic_name, $img_data);这样就可以上传到根目录

D://www/web/public 是你项目根目录吗,当前执行的文件在哪个目录?贴出你的目录结构。

D://www/web/public 是你项目根目录吗,当前执行的文件在哪个目录?贴出你的目录结构。


不是,这个是根目录D://www/web,我想把图片传到D://www/web/public文件夹下

$img_size = file_put_contents("public/". $pic_name, $img_data);
这样呢

$img_size = file_put_contents("public/". $pic_name, $img_data);
这样呢


这样可以了。谢谢了
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