Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
发布:smiling 来源: PHP粉丝网 添加日期:2013-11-29 16:06:51 浏览: 评论:0
今天文件上传出现Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
"150" height="30" align="right" valign="middle">请选择上传文件"250" >"file" name="fileup" />"100" >"submit" name="submit" value="上传" />- if(!emptyempty($_FILES[fileup][name])){
- $fileinfo=$_FILES[fileup];
- $type=strstr($fileinfo['name'],".");
- if($type!=".jpg"){
- echo "您上传的文件格式不正确!";
- }else{
- if($fileinfo['size']<209715 && $fileinfo['size']>0){
- $path="10/".$_FILES["fileup"]["name"];
- move_uploaded_file($fileinfo['tmp_name'],$path);
- if(is_dir("10/")){
- $dir=scandir("10/");
- foreach($dir as $value){
- echo $value."
";- }
- }else{
- echo "目录路径出错!";
- }
- }else{
- echo '文件大小不符合要求!';
- }
- }
- }
- ?>
运行结果:
Warning: move_uploaded_file(10/02.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:appserv-win32-2.5.10AppServwww10index_7.php on line 26
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:WINDOWStempphp1A.tmp' to '10/02.jpg' in E:appserv-win32-2.5.10AppServwww10index_7.php on line 26目录路径出错!
方法一:解决办法,将
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]) 改为:
move_uploaded_file($_FILES["file"]["tmp_name"],"d:/" . $_FILES["file"]["name"])
方法二:Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move,上传的时候出现类似这种报错,原因是目录权限是否为可写的问题。
一般设置777就可以解决,修改权限命令:
- chmod 777 filename
- chmod 777 dirname
- sudo chmod 777 filename/dirname
- chown wangr:admin dirname -R
注:-R 批量执行
Tags: moveuploadedfile move-uploaded-file
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)