现在的位置: 问候seo建站事项>正文

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect

发表于:2016-02-26 当前时间:2017-11-22 分类:建站事项 关键词: 132 views

PHP中调用move_uploaded_file函数提示failed to open stream和 Unable to move
在做一个PHP文件上传系统的时候,使用move_uploaded_file进行文件上传,提示下面两个warning,不能成功上传文件

Warning: move_uploaded_file(upload/songshu_rgb.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\www\2737\upload_file.phpon line 25

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\WINDOWS\Temp\php80.tmp’ to ‘upload/songshu_rgb.gif’ in D:\www\2737\upload_file.phpon line 25
Stored in: upload/songshu_rgb.gif

先前认为是目录权限不够的问题,查找资料后,其实是原因是文件找不到,如何解决呢?查找资料发现,应该使用绝对路径代替相对路径,原来的代码如下

move_uploaded_file($_FILES["file"]["tmp_name"],
upload/” . $_FILES["file"]["name"]);
echo “Stored in: ” . “upload/” . $_FILES["file"]["name"];

修改后:

move_uploaded_file($_FILES["file"]["tmp_name"],
D:/www/2737/upload/” . $_FILES["file"]["name"]);
echo “Stored in: ” . “upload/” . $_FILES["file"]["name"];

注意加亮部分。

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect: http://www.bonledlight.com/1770.html

问候seo分享博客简介

博主:问候SEO经验还行,郑州seo人士,从事计算机教育行业,广交各路seo朋友。

问候博客是致力于新手学习SEO,免费分享SEO基础经验,在线提高SEO水平的最好平台!

邮箱:1448228637@qq.com