Home  >  Article  >  Backend Development  >  关于thinkphp下file_put_contents执行不了问题

关于thinkphp下file_put_contents执行不了问题

WBOY
WBOYOriginal
2016-06-23 13:54:341765browse

$img=file_get_contents("http://img04.taobaocdn.com/bao/uploaded/i4/T1NlTRFLtcXXXXXXXX_!!0-item_pic.jpg");$ret=@file_put_contents('1.jpg',$img);

这段代码放在thinkphp的模块代码下执行不了这是怎么回事啊  file_put_contents这个函数没作用这是为什么呢?


回复讨论(解决方案)

检查一下文件夹的权限。

按照你目前的写法是写入当前目录,检测下当前目录是不是没有读写权限;建议保存到需要保存的可读写的目录中比较好。

1、确定执行到了么?
2、如果执行到了,有不有权限?

你是怎么调用?是写的action方法?

去掉“@”号看看有么有报错。
print_r(error_get_last());

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