热搜:NVER node 开发 php

PHP 表单上传总是“upload NOT successful”

2024-09-20 22:25:01
PHP 表单上传总是“upload NOT successful”

本帖最后由 renye616 于 2013-08-08 11:21:10 编辑

PHP 上传 JavaScript

<?php
include_once 'include/config.php';
include_once 'include/db.php';

include_once 'check.php';

$sss = new HAYA_check();
$applyuser = $sss->user();

//list
$username = $_REQUEST["username"];
$gender = $_REQUEST["gender"];
$testdate = ($_REQUEST["testdate"]=="") ? "0000-0-0" : $_REQUEST["testdate"];
$monaddate = ($_REQUEST["monaddate"]=="") ? "0000-0-0" : $_REQUEST["monaddate"];
$email = $_REQUEST["email"];
$tel1 = $_REQUEST["tel1"];
$tel2 = $_REQUEST["tel2"];
//$listtype = $_REQUEST["listtype"]);
$parentinfo = $_REQUEST["parentinfo"];
$studentinfo = $_REQUEST["studentinfo"];
$continueclass = $_REQUEST["continueclass"];
$studiedclassno = $_REQUEST["studiedClassno"];
$teachername = $_REQUEST["teachername"];
$consultant = $_REQUEST["consultant"];
$assistant = $_REQUEST["assistant"];
$senateclass = $_REQUEST["Senateclass"];
$senateaudit = $_REQUEST["Senateaudit"];
$classno = $_REQUEST["classno"];
$classname = $_REQUEST["classname"];
$grade = $_REQUEST["grade"];
$classsuffix = $_REQUEST["classsuffix"];
$startdate = ($_REQUEST["startdate"]=="") ? "0000-0-0" : $_REQUEST["startdate"];
$enddate = ($_REQUEST["enddate"]=="") ? "0000-0-0" : $_REQUEST["enddate"];
$classfrequency = $_REQUEST["classfrequency"];
$classplace = $_REQUEST["classplace"];
$fee = ($_REQUEST["fee"] == "") ? 0 : $_REQUEST["fee"];
$describe = $_REQUEST["describe"];
$transferfee = ($_REQUEST["transferfee"] == "") ? 0 : $_REQUEST["transferfee"];
$normalnumber = ($_REQUEST["normalnumber"] == "") ? 0 : $_REQUEST["normalnumber"];
$classroom = $_REQUEST["classroom"];
$classarrange = $_REQUEST["classarrange"];
$discount = $_REQUEST["discount"];
$discountreson1 = $_REQUEST["discountreson1"];
$discountreson2 = $_REQUEST["discountreson2"];
$discountreson3 = $_REQUEST["discountreson3"];
$unitprice = $_REQUEST["unitprice"];
$allclassfrequency = ($_REQUEST["allclassfrequency"] == "") ? 0 : $_REQUEST["allclassfrequency"];
$allclasstimes = ($_REQUEST["allclasstimes"] == "") ? 0 : $_REQUEST["allclasstimes"];
$allfee = ($_REQUEST["allfee"] == "") ? 0 : $_REQUEST["allfee"];
$teachbookapplier = $_REQUEST["teachbookapplier"];
$teachbookapplyno = $_REQUEST["teachbookapplyno"];
$lesoncardno = $_REQUEST["lesoncardno"];
$books = $_REQUEST["books"];
// course
$cl = array(
array("name"=>$_REQUEST["cl1_1"],"number"=>$_REQUEST["cl1_2"],"classtime"=>$_REQUEST["cl1_3"],"teacher"=>$_REQUEST["cl1_4"]),
array("name"=>$_REQUEST["cl2_1"],"number"=>$_REQUEST["cl2_2"],"classtime"=>$_REQUEST["cl2_3"],"teacher"=>$_REQUEST["cl2_4"]),
array("name"=>$_REQUEST["cl3_1"],"number"=>$_REQUEST["cl3_2"],"classtime"=>$_REQUEST["cl3_3"],"teacher"=>$_REQUEST["cl3_4"]),
array("name"=>$_REQUEST["cl4_1"],"number"=>$_REQUEST["cl4_2"],"classtime"=>$_REQUEST["cl4_3"],"teacher"=>$_REQUEST["cl4_4"]),
array("name"=>$_REQUEST["cl5_1"],"number"=>$_REQUEST["cl5_2"],"classtime"=>$_REQUEST["cl5_3"],"teacher"=>$_REQUEST["cl5_4"]),
array("name"=>$_REQUEST["cl6_1"],"number"=>$_REQUEST["cl6_2"],"classtime"=>$_REQUEST["cl6_3"],"teacher"=>$_REQUEST["cl6_4"]),
array("name"=>$_REQUEST["cl7_1"],"number"=>$_REQUEST["cl7_2"],"classtime"=>$_REQUEST["cl7_3"],"teacher"=>$_REQUEST["cl7_4"]),
array("name"=>$_REQUEST["cl8_1"],"number"=>$_REQUEST["cl8_2"],"classtime"=>$_REQUEST["cl8_3"],"teacher"=>$_REQUEST["cl8_4"]),
array("name"=>$_REQUEST["cl9_1"],"number"=>$_REQUEST["cl9_2"],"classtime"=>$_REQUEST["cl9_3"],"teacher"=>$_REQUEST["cl9_4"]),
array("name"=>$_REQUEST["cl10_1"],"number"=>$_REQUEST["cl10_2"],"classtime"=>$_REQUEST["cl10_3"],"teacher"=>$_REQUEST["cl10_4"])
);

// arrangetype
$arrangetype = $_REQUEST["arrangetype"];
$arrangetypestr = "";
for($i=0;$i if($i > 0) $arrangetypestr .= " | ";
$arrangetypestr .= $arrangetype[$i];
}

// netclass cards
$netclasscards = $_REQUEST["netclasscards"];
$netclasscardstr = "";
for($i=0;$i if($i > 0) $netclasscardstr .= " | ";
$netclasscardstr .= $netclasscards[$i];
}
//echo $netclasscardstr;

$uploadfilepath = "";
if($_FILES["file"]["name"] != ""){
include_once 'uploadfile.php';
if($upfilename != "" && $upfilename != null) $uploadfilepath = "upload/" . $upfilename;
}

$s = new HAYA_db();

$qinsert = "INSERT INTO JWlist (".
"username,".
"gender,".
"testdate,".
"monaddate,".
"email,".
"tel1,".
"tel2,".
//"listtype,".
"parentinfo,".
"studentinfo,".
"continueclass,".
"studiedclassno,".
"teachername,".
"consultant,".
"assistant,".
"senateclass,".
"senateaudit,".
"classno,".
"classname,".
"grade,".
"classsuffix,".
"startdate,".
"enddate,".
"classfrequency,".
"classplace,".
"fee,".
"describes,".
"transferfee,".
"normalnumber,".
"classroom,".
"arrangetype,".
"classarrange,".
"discount,".
"discountreson1,".
"discountreson2,".
"discountreson3,".
"unitprice,".
"allclassfrequency,".
"allclasstimes,".
"allfee,".
"teachbookapplier,".
"teachbookapplyno,".
"lesoncardno,".
"books,".
"netclasscards,".
"status,".
"applytime,".
"applyuser,".
"uploadfilepath".
") VALUES (".
"'" . $username . "', '" . 
$gender . "', '" .
$testdate . "', '" .
$monaddate . "', '" .
$email . "', '" .
$tel1 . "', '" .
$tel2 . "', '" .
//$listtype . "', '" .
$parentinfo . "', '" .
$studentinfo . "', '" .
$continueclass . "', '" .
$studiedclassno . "', '" .
$teachername . "', '" .
$consultant . "', '" .
$assistant . "', '" .
$senateclass . "', '" .
$senateaudit . "', '" .
$classno . "', '" .
$classname . "', '" .
$grade . "','" .
$classsuffix . "', '" .
$startdate . "', '" .
$enddate . "', '" .
$classfrequency . "', '" .
$classplace . "', '" .
$fee . "', '" .
$describe . "', '" .
$transferfee . "', '" .
$normalnumber . "', '" .
$classroom . "', '" .
$arrangetypestr . "', '" .
$classarrange . "', '" .
$discount . "', '" .
$discountreson1 . "', '" .
$discountreson2 . "', '" .
$discountreson3 . "', '" .
$unitprice . "', '" .
$allclassfrequency . "', '" .
$allclasstimes . "', '" .
$allfee . "', '" .
$teachbookapplier . "', '" .
$teachbookapplyno . "', '" .
$lesoncardno . "', '" .
$books . "', '" .
$netclasscardstr . "', '" . 
"1',".
"now(),'".
$applyuser."','".
$uploadfilepath . "'" .
")";
//echo $qinsert;
$resultstr = $s->query($qinsert);
$lastId = $s->getLastInsertId();
if(!$resultstr) echo '';
else{
//$q2 = "SELECT MAX(ID) FROM JWlist";
//$rsID = $s->query($q2);
//echo $lastId;
//echo "cl count : ".count($cl);
for($i=0;$i if($cl[$i]["name"] == null || $cl[$i]["name"] == "") continue;
$qinsert2 = "INSERT INTO course (".
"listID,".
"name,".
"number,".
"classtime,".
"teacher".
") VALUES (".
"'" . $lastId . "', '" . 
$cl[$i]["name"] . "', '" .
$cl[$i]["number"] . "', '" .
$cl[$i]["classtime"] . "', '" .
$cl[$i]["teacher"] . "'" .
")";
//echo $qinsert2;
$result2 = $s->query($qinsert2);
if(!$result2) echo "false";
else echo "true";
}
echo '';
}
//echo '';

?>

====================== ================
=============php 配置文件=======================
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; http://www.php.net/manual/en/ini.core.php#ini.file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir
upload_tmp_dir = /var/www/html/upload

; Maximum allowed size for uploaded files.
; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
upload_max_filesize = 10M

回复讨论(解决方案)

所有文件都不行?小文件试了吗?

所有文件都不行?小文件试了吗?  其他可以正常上传。
之前有一份正常运行的网页程序,都可以正常上传,现在发的这个代码和这个代码相关的.php文件都已经确认跟之前程序 代码以至。    变的 只是 平台  由windows 变为 linux    apache配置  和 mysql配置和mysql库都 都跟以前是一致的,(当然linux 和windows配置有区别这个可以忽略)  网页其他运行都正常。 就是这个表单总是提交以后提示 NOT successful...

if(!$resultstr) echo '';
显然是查询失败了 $resultstr = $s->query($qinsert);
你打印出 $qinsert 看看
如果有中文请注意编码

if(!$resultstr) echo '';
显然是查询失败了 $resultstr = $s->query($qinsert);
你打印出 $qinsert 看看
如果有中文请注意编码 utf8_general_ci可以不  是包含中文的

utf8_general_ci 只是说内容按 utf8 存储,不表示你给他的数据是正确的

除非你在安装 mysql 时做了字符集设置(即便做了也不见得就是utf8的),否则都是 latin1 的
所以都应该有执行 set names 页面编码

$resultstr = $s->query($qinsert);输出$resultstr瞧瞧。

utf8_general_ci 只是说内容按 utf8 存储,不表示你给他的数据是正确的

除非你在安装 mysql 时做了字符集设置(即便做了也不见得就是utf8的),否则都是 latin1 的
所以都应该有执行 set names 页面编码

都已经设置成 UTF8 PHP里是默认 mysql_query("set names ‘utf8’")问题依旧

$resultstr = $s->query($qinsert);输出$resultstr瞧瞧。


$resultstr = $s->query($qinsert);输出$resultstr瞧瞧。
具体怎么输出呢  

如果以前有编码问题,那么只用修改后插入的数据才可能是正确的

如果以前有编码问题,那么只用修改后插入的数据才可能是正确的 以前没有编码问题