file_put_contents() failed to open stream: Permission denied 问题解决
很长时间没有写PHP了,今天突然有个需求要写一个保存文件的功能。
function downloadFile( $url , $savePath = '' )
{
$fileName = getUrlFileExt( $url );
$fileName = rand(0,1000). '.' . $fileName ;
$file = file_get_contents ( $url );
file_put_contents ( $savePath . '/' . $fileName , $file );
return $fileName ;
}
调用downloadFile( "http://www.xxx.com" , "/bak" );
怎么都不行,一直提示file_put_contents() failed to open stream: Permission denied
后面把文件夹权限也加上还是不行,郁闷了。
最后突然想到地址不应该是相对的哦。
改为downloadFile( "http://www.xxx.com" , rtrim($_SERVER['DOCUMENT_ROOT'],'/')."/bak" ); 搞定了,哎要是换成以前肯定一下就想到了。
file_put_contents() failed to open stream: Permission denied 问题解决的更多相关文章
- Warning: file_put_contents(data.txt): failed to open stream: Permission denied in /Library/WebServer/Documents/test.php on line 22
最近在学习PHP 在保存文件的时候报Warning: file_put_contents(data.txt): failed to open stream: Permission denied in ...
- file_put_contents () failed to open stream: Permission denied 解决办法
今天,帮朋友配置服务器thinkphp5的时候,直接访问“www.***.com/admin/index/index” : 出现以下错误: file_put_contents (/PHP/admin/ ...
- php上传文件时出现错误:failed to open stream: Permission denied
尝试使用php写了一段小的上传程序,但是在使用的时候,在上传文件时出现这个错误,由于之前在写程序要读文件,曾经出现过这个问题,当时是因为要读的文件的权限不够,于是使用chmod 775 1.txt把文 ...
- [置顶] PHP调用move_uploaded_file()提示 failed to open stream: Permission denied(Linxux环境,以Ubuntu12.04为例)
在使用PHP上传文件之后,我们有时候还需要移动到特定的文件夹,这时候就要调用move_uploaded_file()函数,可是会出现如下错误: Warning: move_uploaded_file( ...
- easyhadoop:failed to open stream:Permission denied in /var/www/html/index.php
今天又重新部署了下easyhadoop,结果apache后台服务器报这个错误: [Fri Dec 13 10:32:41 2013] [notice] SIGHUP received. Attempt ...
- failed to open stream: Permission denied in警告错误
问题是文件所在目录的权限问题导致的.只需要将警告文件所在的目录权限更改为777(至少是006)即可 例如 (...a.log)failed to open stream: Permission den ...
- laravel he stream or file "..laravel-2019-02-14.log" could not be opened: failed to open stream: Permission denied
错误:The stream or file "/var/www/jianshu/storage/logs/laravel-2019-02-14.log" could not be ...
- docker 错误failed to open stream: Permission denied 解决方法
在服务器上面.运行docker时,php目录会发生权限问题解决方法如下: 1:进入php目录下面 docker exec -ti php56 /bin/bash #进入php容器 chown -R w ...
- move_uploaded_file failed to open stream permission denied
Make sure that: IWPG_user, where user is a system user of the subscription who has rights to "R ...
随机推荐
- Android-xUtils框架介绍(三)
继续介绍xUtils的最后两个模块:DbUtils和HttpUtils.首先先介绍第一个SQLite数据库操纵的简单ORM框架,只要能理解xUtils为我们提供的api,相信你也能熟练的把DbUtil ...
- Windows 7/8 自带定时关机命令
快捷键“Windows + R”,输入cmd打开cmd.exe程序,输入以下对应命令. 两种定时关机方式: 定时任务法 输入命令“at hh:mm shutdown -s”,Enter——添加了一 ...
- POJ 2586 Y2K Accounting Bug(贪心)
题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0) ...
- (二)学习CSS之cursor属性
参考:http://www.w3school.com.cn/tiy/t.asp?f=csse_zindex cursor 属性规定要显示的光标的类型(形状). <html> <bod ...
- SharePoint 2013 Pop-Up Dialogs
转:http://blog.csdn.net/tristan_dong/article/details/19076315 自定义弹出框 一. 项目需求: 自定义弹出框,包括弹出框的内容和样式. 说明: ...
- 我的WCF之旅(3):在WCF中实现双工通信
双工(Duplex)模式的消息交换方式体现在消息交换过程中,参与的双方均可以向对方发送消息.基于双工MEP消息交换可以看成是多个基本模式下(比如请求-回复模式和单项模式)消息交换的组合.双工MEP又具 ...
- 自杀程序&递归删除目录
自杀程序,删掉自身,包括执行程序所在的文件夹. 仅在windows下进行了测试,使用语言C# string fileName = Path.GetTempPath() + "killmyse ...
- 16、传感器(Sensor)
一.什么是传感器 传感器是一种物理装置或生物器官,能够探测.感受外界的信号.物理条件(如光.热.湿度)或化学组成(如烟雾),并将探知的信息传递给其他装置或器官.国家标准GB7665—87对传感器的定义 ...
- POJ 1661 Help Jimmy
/*96655 's source code for M Memory: 8604 KB Time: 63 MS Language: G++ Result: Accepted */ #include& ...
- 3D魔方游戏
初学OpenGL时做的小程序,涉及到了OpenGL的大部分基本内容,如视图模型变换.色彩.纹理贴图.材质.光照.显示列表.选择等 三阶魔方有3×3×3个方块组成,每个方块的类当中都有一个4×4的矩阵, ...