Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

今天文件上传出现Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

 

<form action="" enctype="multipart/form-data" method="post">
<tr>
  <td width="150" height="30" align="right" valign="middle">请选择上传文件</td>
  <td width="250"><input type="file" name="fileup" /></td>
  <td width="100"><input type="submit" name="submit" value="上传" /></td>
</tr>
</form>
<?php教程
if(!empty($_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."<br/>";
                   }
                 }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:apps教程erv-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
目录路径出错!

解决办法,把相对路径改绝对

$_SERVER[DOCUMENT_ROOT] . '/10/' . $_FILES['fileup']['name'];

解决办法

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 批量执行

时间: 2024-10-09 09:09:25

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move的相关文章

Warning: session_start() [function.session-start]: open_basedir restriction in effect. File解决方法

Warning: session_start() [function.session-start]: open_basedir restriction in effect. File解决方法 Warning: include() [function.include]: open_basedir restriction in effect. File(/www/webpublic_html/admin/inc/inc.php教程) is not within the allowed path(s)

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server

我有一台服务器win2003SP1+sqlserver2000(已打上SP4补丁) PHP远程连接sql2000 连接失败是什么情况? 1.服务器本机测试可连接! 2.在自己的电脑上用查询分析器也可以连上! 服务器上的1433端口在监听 sql2000的用户名.密码没错,权限也没问题! ntwdblib.dll 版本是2000.80.194.0 apache.php.system32目录下的都已近更新 ntwdblib.dll和php_mssql.dll   都已经复制到system32目录下

php提示 Warning: touch() [function.touch]: Utime failed: Permission denied in错误

使用timthumb.php出现Warning: touch() [function.touch]: Utime failed: Permission denied in错误 我们先来看一下touch()函数例子 touch() 函数设置指定文件的访问和修改时间. touch(filename,time,atime) 例子  代码如下 复制代码 <?php touch("test.jpg"); ?> 应用例子时出现错误 用timthumb.php来做缩略图,本地测试很OK,

PHP错误WARNING: SESSION_START() [FUNCTION.SESSION-START]解决方法_php技巧

做开发的时候,操作session有时候会遇到这个问题:Warning: session_start() [function.session-start]-- 系统环境:WIN2003+IIS6+PHP5.2.12 PHP出现类似如下错误: Warning: session_start()[function.session-start]: ...... failed: No such file or directory......等情况, 可以偿试修改一下php.ini文件中的session.au

Warning: mssql_connect() [function.mssql-connect]:

我是这样做的,确定mssql是正常的用户名密码也可以,但下面就是不行. <?php教程  $con=mssql_connect( "localhost", "sa ", "123456 ") or die ('error');    ?>  错误提示  warning: mssql_connect() [function.mssql-connect]: unable to connect to server: $sa in d:php

Warning: mysql_connect() [function.mysql-connect]: [2002] 由于目标机器积极拒绝,无法连接

错误代码如下 aabb Warning: mysql_connect() [function.mysql-connect]: [2002] 由于目标机器积极拒绝,无法连接. (trying to connect via tcp://localhost:3306) in X:test7.php on line 6 Warning: mysql_connect() [function.mysql-connect]: 由于目标机器积极拒绝,无法连接. in X:test7.php on line 6

Warning: session_start() [function.session-start]

我的电脑中的错误提示 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:APMServ-v5.2.6APMServ5.2.6wwwhtdocsKingNerOAuserUserKqManage.php:1) in D:APMServ-v5.2.6APMServ5.2.6wwwhtdocsKi

Warning: mssql_query() [function.mssql-query]:

Warning: mssql_query() [function.mssql-query]: message: 不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使用 Unicode 排序规则的 Unicode 数据发送到客户端. (severity 16) in F:\myweb\lzlj\cn.php on line 21 Warning: mssql_query() [function.mssql-query]: Query failed

php Warning:strstr()[function.strstr]:Empty delimiter

Warning: strstr() [function.strstr]: Empty delimiter 非常奇怪,难道php函数strstr的某个参数出问题了? 于是写了个测试的例子  代码如下 复制代码 <?php $text="asdfghjklqwertyuiopzxcvbnm"; //$key="g"; //根据php错误提示Empty delimiter,判断应该不会是$text的值出问题,所以故意注释了key值 if(strstr($text,