因为在做一个文件传输系统,所以用了swfupload,用的也是php100的版本。虽然自己有较大改动吧,但之前测试也都成功的。今天整个系统做的差不多,发现swfupload出问题了。上传后报500错误,经测试,好像是session没有传递成功。但是我不知道怎么改,文件夹的权限已经全开,不知道怎么回事。测试环境是xp下,ie6.下面附上代码
上传页面:变化不大,页面我还没怎么设计。
<?php include('conn/conn.php');
include('globle.php')
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<meta http-equiv="Content-Type" content="text/html"; charset="gb2312">
<head>
<title> 文件管理系统</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/swfupload.queue.js"></script>
<script type="text/javascript" src="js/fileprogress.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
        var swfu;        window.onload = function() {
            var settings = {
                flash_url : "swfupload/swfupload.swf",
                upload_url: "prossess.php",   
                post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
                file_size_limit : "1000 MB",
                file_types : "*.*",
                file_types_description : "All Files",
                file_upload_limit : 10,  //配置上传个数
                file_queue_limit : 0,
                custom_settings : {
                    progressTarget : "fsUploadProgress",
                    cancelButtonId : "btnCancel"
                },
                debug: false,                // Button settings
                button_image_url: "../image/TestImageNoText_65x29.png",
                button_width: "65",
                button_height: "29",
                button_placeholder_id: "spanButtonPlaceHolder",
                button_text: '<span class="theFont">浏览</span>',
                button_text_style: ".theFont { font-size: 16; }",
                button_text_left_padding: 12,
                button_text_top_padding: 3,
               
                file_queued_handler : fileQueued,
                file_queue_error_handler : fileQueueError,
                file_dialog_complete_handler : fileDialogComplete,
                upload_start_handler : uploadStart,
                upload_progress_handler : uploadProgress,
                upload_error_handler : uploadError,
                upload_success_handler : uploadSuccess,
                upload_complete_handler : uploadComplete,
                queue_complete_handler : queueComplete   
            };            swfu = new SWFUpload(settings);
         };     
       
    </script>
   
</head>
<body>
<div id="main">
  <div id="header">    <div id="menu2" class="menu">
            <ul>
                <li><a href="userinfo.php">个人信息</a></li>
                <li><a href="yscwj.php">已上传文件</a></li>
                <li><a href="filelist.php">文件查看</a></li>
                <li><a href="upload.php">文件上传</a></li>
                <li><a href="docsend.php">文件发送</a></li>
                <li><a href="index.php">退出系统</a></li>
      </ul>
</div>
    </div>
   
<div id="content">    <form id=form1  onSubmit="return ck_reg()" action="prossess.php" method="post" enctype="multipart/form-data" >
        <p>点击“浏览”按钮,选择您要上传的文档文件后,系统将自动上传并在完成后提示您。</p>
        <p>请勿上传包含中文文件名的文件!</p>
        <div class="fieldset flash" id="fsUploadProgress">
            <span class="legend">快速上传</span>
      </div>
        <div id="divStatus">0 个文件已上传</div>
            <div>
                <span id="spanButtonPlaceHolder"></span>
                <input id="btnCancel" type="button" value="取消所有上传" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 10pt; height: 28px;" />
            </div>    </form>
</div>
<div align="center"> <a href="" target="_blank"></a>
</div>
</div>
</body>
</html>
prossess 页,也就是原来的upload,只是加了些数据库和文件夹的操作。一开始测试成功。
<?phpinclude("conn/conn.php");
include("globle.php");
include("class/file.class.php");if (isset($_POST["PHPSESSID"])) {
        session_id($_POST["PHPSESSID"]);
    } else if (isset($_GET["PHPSESSID"])) {
        session_id($_GET["PHPSESSID"]);
    }
    session_start();
    $POST_MAX_SIZE = ini_get('post_max_size');
    $unit = strtoupper(substr($POST_MAX_SIZE, -1));
    $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));    if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) {
        header("HTTP/1.1 500 Internal Server Error");
        echo "POST exceeded maximum allowed size.";
        exit(0);
    }//本地相关操作
$str_province=$_POST['province'];  //部门
$user_dir=FileUtil::createDir("/file/".$str_userbh);// Settings
    $save_path = getcwd() . "/file/".$str_userbh."/";
    $upload_name = "Filedata";
    $max_file_size_in_bytes = 2147483647;                // 2GB in bytes
    $save_dir="file/".$str_userbh."/";
    //$extension_whitelist = array("doc", "txt", "jpg", "gif", "png","rar","zip","php");    //允许的文件
    $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-';                //允许的文件名字符
    $localtime=date('Y-m-d H:i:s', time());
   
// Other variables   
    $MAX_FILENAME_LENGTH = 260;
    $file_name = "";
    $file_extension = "";
    $uploadErrors = array(
        0=>"文件上传成功",
        1=>"上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
        2=>"上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
        3=>"上传的文件仅为部分文件",
        4=>"没有文件上传",
        6=>"缺少临时文件夹"
    );
//查找最大的文件编号
$sqlmaxfilebh = "Select MAX(filebh) as maxbh FROM wj_info " ;
//echo $sqlschmaxfilebh;
$resultmaxfilebh=mssql_query($sqlmaxfilebh) or die("不能查询指定的数据!".mssql_get_last_message());
$row_maxfilebh = mssql_fetch_assoc($resultmaxfilebh);
$maxfilebh = $row_maxfilebh['maxbh'] + 1; 
$xymaxfilebh =$row_maxfilebh['maxbh'] ;
//echo $maxfilebh;
//echo $xymaxfilebh;//查找人员
$sqlsch = "Select uid,ckrbh,ckrname,scrbh,scrname,lrtime FROM lsb_info
where  scrbh='$str_userbh' Order By uid " ;//echo $sqlsch;    if (!isset($_FILES[$upload_name])) {
        HandleError("No upload found in \$_FILES for " . $upload_name);
        exit(0);
    } else if (isset($_FILES[$upload_name]["error"]) && $_FILES[$upload_name]["error"] != 0) {
        HandleError($uploadErrors[$_FILES[$upload_name]["error"]]);
        exit(0);
    } else if (!isset($_FILES[$upload_name]["tmp_name"]) || !@is_uploaded_file($_FILES[$upload_name]["tmp_name"])) {
        HandleError("Upload failed is_uploaded_file test.");
        exit(0);
    } else if (!isset($_FILES[$upload_name]['name'])) {
        HandleError("File has no name.");
        exit(0);
    }
   
    $file_size = @filesize($_FILES[$upload_name]["tmp_name"]);
    if (!$file_size || $file_size > $max_file_size_in_bytes) {
        HandleError("File exceeds the maximum allowed size");
        exit(0);
    }
   
    if ($file_size <= 0) {
        HandleError("File size outside allowed lower bound");
        exit(0);
    }
    $file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
    if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) {
        HandleError("Invalid file name");
        exit(0);
    }
 
    if (file_exists($save_path . $file_name)) {
        HandleError("File with this name already exists");
        exit(0);
    }// Validate file extension
    $path_info = pathinfo($_FILES[$upload_name]['name']);
    $file_extension = $path_info["extension"];
    $is_valid_extension =true;
    foreach ($extension_whitelist as $extension) {
        if (strcasecmp($file_extension, $extension) == 0) {
            $is_valid_extension = true;            break;
        }
    }
    if (!$is_valid_extension) {
        HandleError("Invalid file extension");
        exit(0);
    }      For($i=1;$i<=$row_user;$i++)
{
$row_Member = mssql_fetch_assoc($result_user);  
$str_bh=trim($row_Member['ckrbh']);
}
 $file_name=date('H-i', time()).$file_name;
    if (!move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) {
        HandleError("文件无法保存.");
        exit(0);
    }else{
        mssql_select_db("doctransf",$wjglxt)or die("数据库连接不成功");
        $sql="insert into wj_info (filebh,filename,filerealname,scrbh,scrname,scrbm,ckrbh,lrtime)values('$maxfilebh','$save_dir','$file_name','$str_userbh','$str_username','$str_userbm','$str_bh','$localtime')";
        //$sql="insert into wj_info (uid,filename,filerealname) values (null,$save_path','$file_name')";
        $result=mssql_query($sql);
    if(!$result)
     echo mssql_get_last_message();
    }
       echo "File Received";
    exit(0);
/*$sqldel="Delete From lsb_info Where scrbh=$str_userbh";
mssql_query($sqldel) or die("删除数据出错!".mssql_get_last_message());echo "<script>alert('数据保存成功!')</script>";
echo "<meta http-equiv=refresh  content=0;url=wjsc.php>";*/
function HandleError($message) {
    header("HTTP/1.1 500 Internal Server Error");
    echo $message;
}?>

解决方案 »

  1.   

    其实应该不是代码的问题,因为我试过直接用swfupload的官网demo也不行。从D盘换E盘也不行,iis+mssql换apache+mysql也不行。
      

  2.   

    if (isset($_POST["PHPSESSID"])) {
      session_id($_POST["PHPSESSID"]);
      }
    只要$_GET
      

  3.   

    试过了,还是一样。flash显示的错误信息不明,都不知道到底怎么错了
      

  4.   

    下载的demo 也行不?????
    服务器端写日志 ,把所以接收的包都用日志记下来。
    慢慢来,一步一步的调过去。