PHP程序liunx下图片上传功能有问题,windows下正常不知道是什么原因。程序本身已经测试没有任何问题。之前一直运行都正常,重启了下服务器就成这样了。以前也有重启服务器,但是一切都正常。
文件夹权限是755,全部设置成777还是不正常。

解决方案 »

  1.   

    1、先看php.ini中是否指明了upload_tmp_dir,如果是,看看该位置是否存在;
    2、使用chmod -R 777 /tmp命令覆盖/tmp的访问权限。如果存在upload_tmp_dir,则也将这个位置的权限覆盖;
    3、看看php.ini中的upload_max_filesize和post_max_size是否设置正确,如果设置的较低应该改大。
      

  2.   

    错误提示是“上传失败”。然后显示404页面。upload_max_filesize和post_max_size设置都很正确。
    /tmp设置成777问题依然存在upload_tmp_dir我登录到服务器上,我只能通过SSH。所以我没找到PHP.ini目录
      

  3.   

    方法一:建个新php脚本,内容是
    <?php
    phpinfo();
    然后访问,里面有一个Loaded Configuration File 就是PHP.ini的位置。
    方法二:用ssh:
    cd /
    find | grep php.ini
    就能找到了。找到后,先设置display_errors = On
    然后看看上传失败具体是什么错误。
      

  4.   

    <?php
    include './admin_mysql.php';
    global $db;
    @extract($db->get_one("select * from bh_center where id='1'"));if($_FILES['file'])
    {

    if($T_name=='apic')
    include './admin_upload_apic.php';
    elseif($T_name=='bpic')
    include './admin_upload_bpic.php';

    if(empty($shuiy))
    {
    $fName = $updir."/".$time.$typeq;

    //move_uploaded_file 这个函数返回False;
    if(@move_uploaded_file($_FILES['file']['tmp_name'], $fName))
    {
     @chmod($updir,0777);
     $fileurl=$updir.$fName;
     $fileurl="".$fName;
     //生成缩略图
     if(!empty($makebpic))
     {
       $fileurl_name=str_replace($typem,"_x".$typem,$fileurl);
     $fileurlname=str_replace($typem,"_x",$fileurl);
     $minipic=miniature($fileurl,$fileurlname,$x_width,$x_height);
     if($minipic==true)
     $fileurl_x=$fileurl_name;
     else
     $fileurl_x="";  
     }
     else
     $fileurl_x="";
     @chmod($fileurl,0777);
     @chmod($fileurl_x,0777);
    }
    else
    {
    echo "上传失败!";
    echo "<script>location.href=history.back()</script>";
    }
    }
    else
    {
    $waterText = array('WWW.CHXK.COM', 'all rights reserved');
    if($file = waterMark($_FILES['file']['tmp_name'], $waterText))
    {
     @chmod($file, 0777);
     $fileurl=$file;
     $fileurl="".$file;
     //生成缩略图
     if(!empty($makebpic))
     {
     $fileurl_name=str_replace($typem,"_x".$typem,$fileurl);
     $fileurlname=str_replace($typem,"_x",$fileurl);
     $minipic=miniature($fileurl,$fileurlname,$x_width,$x_height);
     if($minipic==true)
     $fileurl_x=$fileurl_name;
     else
     $fileurl_x="";  
     }
     else
     $fileurl_x="";
     @chmod($fileurl,0777);
     @chmod($fileurl_x,0777);
    }
    else
    {
    echo "上传失败!";
    echo "<script>location.href=history.back()</script>";
    }
    }
    // ----------------------------------------------------------------------------------------------//
    }

    ?>
    <html>
    <head>
    <title>上传小图</title>
    <script language="JavaScript">
    function isnull()
    {
             if(document.all.fileurl.value!="")insert();
    }
    function insert()
    {
    window.opener.document.all.<?echo $T_name;?>.value=insertpic.fileurl.value;
    if(document.all.fileurl_x.value!="")
    {
    window.opener.document.all.bpic.value=insertpic.fileurl_x.value;
    }
    window.close();}
    </script>
    <style>
    BODY {FONT-SIZE: 12px;FONT-FAMILY: tahoma,宋体;}
    TABLE {empty-cells: show;}
    TD{FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: tahoma,宋体;margin: 5}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 bgcolor='cccccc' style="border:0px" onload=isnull()>
    <?php
    if($uppicmake=='0')
    {
    echo "<table height='118'>
    <tr><td width='400' height='100' align='center'><font color='#ff000'>对不起,系统设置禁止了图片上传功能。</font></td>
    </tr></table>";
    exit();
    }
    ?>
    <form action='admin_upapic.php?T_name=<?echo $T_name;?>' name=insertpic enctype=multipart/form-data method=post>
      <table align="center" bgcolor="#CCCCCC">
        <tr>
          <td width=60>上传图片</td>
          <td width="251"><input type="file" name="file" size="14">
            <input type="submit" value="上传" ></td>
        </tr>
        <?php
    if($shuiyinmake=='1')
    echo "<tr><td colspan=2 align=left>
      <input name='shuiy' type='checkbox'  value='1'>
          给图片添加水印(注:BMP和动态GIF不支持水印功能)</td></tr>";
    ?>
       <tr>
       <td colspan=2 align=left>
      <input name='makebpic' type='checkbox'  value='1'>
          自动生成所略图&nbsp;&nbsp;
      宽:<input type="text" name="x_width" size="2" value="70"> px &nbsp;
      高:<input type="text" name="x_height" size="2" value="90"> px
       </td>
       </tr>
        <tr>
          <td>图片URL</td>
          <td><input type="text" name="fileurl" value="<?=$fileurl?>" size="26">
      <input type="hidden" name="fileurl_x" value="<?=$fileurl_x?>" size="26">
            <button onclick=insert()>插入</button></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
      

  5.   

    本帖最后由 xuzuning 于 2011-07-29 20:46:01 编辑
      

  6.   

    Parse error: syntax error, unexpected '[', expecting ']' in /www/users/hy.cnwest.cc/admin/main/admin_upapic.php on line 18
      

  7.   

    会不会是apache用户组权限问题。程序本身是正常。昨天还能够正常使用。服务器下很多站点都用这套程序开发的。现在使用这套程序开发的就出现此类问题。
      

  8.   

    如果上传功能在windows下完全正常。
    那应该要么是大小写问题,要么是权限问题。
    改下错误输出级别,输出所有的错误和警告看看。
      

  9.   

    几个问题:
    1.你的$updir,$time,$typeq,$T_name是在哪里定义的?
    2.sql语句中为什么是id='1' 而不是id=1?