PHP的基本语法学习的差不多了,现在开始学习PHP的文件上传功能实现了。功能中使用到了move_uploaded_file方法,运行时报错: failed to open stream。

经过查资料,总结了出现该错误的几个可能的原因及解决方法。

原因一:移动到的目录的写法不正确

我的目录如下所示:



这是《PHP和MySQL Web开发》第四版中的例子,我的PHP版本是7.0.2,执行时报了failed to open stream错误。这种错误有两种解决方法:第一写绝对路径,如“D:/uploads/”;第二:使用相对路径时,使用“./uploads/”表示移动文件到当前默认目录下的uploads目录下,或者使用“../uploads/”表示移动文件到当前目录的父目录下的uploads目录下。

原因二:移动到的目录不存在

如果移动到的目录不存在,也会报failed to open stream错误。创建对应的目录即可解决问题。

move_uploaded_file的failed to open stream错误处理的更多相关文章

  1. [置顶] PHP调用move_uploaded_file()提示 failed to open stream: Permission denied(Linxux环境,以Ubuntu12.04为例)

    在使用PHP上传文件之后,我们有时候还需要移动到特定的文件夹,这时候就要调用move_uploaded_file()函数,可是会出现如下错误: Warning: move_uploaded_file( ...

  2. php上传文件时出现错误:failed to open stream: Permission denied

    尝试使用php写了一段小的上传程序,但是在使用的时候,在上传文件时出现这个错误,由于之前在写程序要读文件,曾经出现过这个问题,当时是因为要读的文件的权限不够,于是使用chmod 775 1.txt把文 ...

  3. PHP中调用move_uploaded_file函数提示failed to open stream和 Unable to move

    在做一个PHP文件上传系统的时候,使用move_uploaded_file进行文件上传,提示下面两个warning,不能成功上传文件 Warning: move_uploaded_file(uploa ...

  4. Laravel访问出错错误信息:`Warning: require(/vendor/autoload.php): failed to open stream: No such file or dire

    错误信息:`Warning: require(/http/www.mywakavLee.cn/bootstrap/../vendor/autoload.php): failed to open str ...

  5. file_put_contents 错误:failed to open stream: Invalid argument 一种原因

    今天在测试nilcms系统的时候,出现了一个报错,导致缓存无法更新: file_put_contents(C:\UPUPW_AP5.4\vhosts\d.tv\NilCMS_APP\include_r ...

  6. failed to open stream: Permission denied in警告错误

    问题是文件所在目录的权限问题导致的.只需要将警告文件所在的目录权限更改为777(至少是006)即可 例如 (...a.log)failed to open stream: Permission den ...

  7. 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 ...

  8. php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决

    在使用file_get_contents方法来获取远程文件时会出现 [function.file-get-contents]: failed to open stream: HTTP request ...

  9. 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 ...

随机推荐

  1. Linux OpenGL 实践篇-1 OpenGL环境搭建

    本次实践所使用环境为CentOS 7. 参考:http://www.xuebuyuan.com/1472808.html OpenGL开发环境搭建: 1.opengl库安装 opengl库使用mesa ...

  2. java设计模式之代理设计模式(Proxy)

    一个简单Proxy代理模式范例 interface Subject{ //定义核心主题所要完成的功能 public void make(); } class RealSubject implement ...

  3. localStorage学习总结

    一.本地存储 在HTML5诞生之前,网站如果想在浏览器端存储数据,只能使用Cookie,使用Cookie有较多的限制. Cookie问题: 1.cookie大小限制在4K左右(各个浏览器不一致) 2. ...

  4. cogs 619. [金陵中学2007] 传话

    提交地址:http://cojs.tk/cogs/problem/problem.php?pid=619 619. [金陵中学2007] 传话 ★☆   输入文件:messagez.in   输出文件 ...

  5. [HAOI 2011]向量

    Description 题库链接 给你一对数 \(a,b\) ,你可以任意使用 \((a,b), (a,-b), (-a,b), (-a,-b), (b,a), (b,-a), (-b,a), (-b ...

  6. [WC 2011]Xor

    Description Input 第一行包含两个整数N和 M, 表示该无向图中点的数目与边的数目. 接下来M 行描述 M 条边,每行三个整数Si,Ti ,Di,表示 Si 与Ti之间存在 一条权值为 ...

  7. ●BZOJ 2005 NOI 2010 能量采集

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2005 题解: 一个带有容斥思想的递推.%%% 首先,对于一个点 (x,y) 在路径 (0,0 ...

  8. 【TCP网络协议问题】

    题目描述 在如今的网络中,TCP 是一种被广泛使用的网络协议,它在传输层提供了可靠的通信服务.众所周知,网络是存在时延的,例如用户先后向服务器发送了两个指令 op1 和 op2,并且希望服务器先处理指 ...

  9. hdu 5534(dp)

    Input The first line contains an integer T indicating the total number of test cases. Each test case ...

  10. Redis wind7 安装

    下载地址:https://github.com/MSOpenTech/redis/releases. Redis 支持 32 位和 64 位.这个需要根据你系统平台的实际情况选择,这里我们下载 Red ...