| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1000 人关注过本帖
标题:救教php上传问题
只看楼主 加入收藏
llk726
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-9-6
收藏
 问题点数:0 回复次数:0 
救教php上传问题
大家帮我看看这段代码,它在windows下的appsrv下能执行,可上传到linux下不能执行?我不知是哪里的问题呀?
<?php
session_start();
include "conn/conn.php";
$tjname=$_SESSION[username];
$tjzq=$_POST[zq];
$tjzhti=$_POST[zhuti];
$tjuser=$_POST[user];
echo "$tjname <br>";
echo "$tjzq <br>";
echo "$tjzhti <br>";
echo "$tjuser <br>";
$furl=getenv("http_referer");
$time=date("y-m-d h:m:s");
if($zttj){
$uploaddir="./upfiles/";
$type=array("jpg","gif","bmp","jpeg","png","pdf","doc");
 function fileext($filename)
    {
        return substr(strrchr($filename, '.'), 1);
    }
function random($length)
    {
        $hash = 'CR-';
        $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
        $max = strlen($chars) - 1;
        mt_srand((double)microtime() * 1000000);
            for($i = 0; $i < $length; $i++)
            {
                $hash .= $chars[mt_rand(0, $max)];
            }
        return $hash;
    }

   $a=strtolower(fileext($_FILES['file3']['name']));

        if(!in_array(strtolower(fileext($_FILES['file3']['name'])),$type))
     {
        $text=implode(",",$type);
        echo "您只能上传以下类型文件: ",$text,"<br>";
     }
   else{
    $filename=explode(".",$_FILES['file3']['name']);
        do
        {
            $filename[0]=random(8);
            $name=implode(".",$filename);
            $uploadfile=$uploaddir.$name;
        }
   while(file_exists($uploadfile));
        if (move_uploaded_file($_FILES['file3']['tmp_name'],$uploadfile)){
          $query="insert into tb_zqlb (zq,zhuti,neirong,username,fbsj)values('$tjzq','$tjzhti','$uploadfile','$tjuser','$time')";
           $result=mysql_query($query);
          if($result==true){
                echo "<center>您的文件已经上传完毕 上传图片预览: </center><br><center><img src='$uploadfile'></center>";
                echo"<br><center><a href='javascript:history.go(-1)'>继续上传</a></center>";
              }
              else{
                echo "上传失败!";
          echo "<meta http-equiv=\"Refresh\" content=\"3;url=fbzt.php\">";}}}}
?>
搜索更多相关主题的帖子: php 
2008-09-06 11:57
快速回复:救教php上传问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.071995 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved