我一次上传5个文件。上传成功但当我想更新某些特定文件,如文件1和文件2时,其他文件不应该更改,它必须是它的..但在我的情况下,它去了空白......我的代码是
if(isset($_REQUEST['update']))
{
$img1 = $_FILES['file_img1']['name'];
$fileElementName = 'file_img1';
$path = 'upload/';
$location = $path . $_FILES['file_img1']['name'];
move_uploaded_file($_FILES['file_img1']['tmp_name'], $location);
$img2 = $_FILES['file_img2']['name'];
$fileElementName = 'file_img2';
$path = 'upload/';
$location = $path . $_FILES['file_img2']['name'];
move_uploaded_file($_FILES['file_img2']['tmp_name'], $location);
$img3 = $_FILES['file_img3']['name'];
$fileElementName = 'file_img3';
$path = 'upload/';
$location = $path . $_FILES['file_img3']['name'];
move_uploaded_file($_FILES['file_img3']['tmp_name'], $location);
$img4 = $_FILES['file_img4']['name'];
$fileElementName = 'file_img4';
$path = 'upload/';
$location = $path . $_FILES['file_img4']['name'];
move_uploaded_file($_FILES['file_img4']['tmp_name'], $location);
$img5 = $_FILES['file_img5']['name'];
$fileElementName = 'file_img5';
$path = 'upload/';
$location = $path . $_FILES['file_img5']['name'];
move_uploaded_file($_FILES['file_img5']['tmp_name'], $location);
$sel="update tbl_job_schedule set
file1='$img1',
file2='$img2',
file3='$img3',
file4='$img4',
file5='$img5',
status='schwork',
user_cmntdate=now(),
cmnt='".$_REQUEST['addcmnt']."' where clientname='".$rw['clientname']."' and username='".$_SESSION['user']."' and jobdate='".$_SESSION['strmonth']."-".$_REQUEST['dt']."-".$_SESSION['yy']."'";
mysql_query($sel) or die($sel);
}
答案 0 :(得分:0)
在更新数据库之前检查所有参数是否都为空,您将得到问题的答案。
由于
答案 1 :(得分:0)
如果检查文件的条件是否存在
if(isset($_REQUEST['update']))
{
if($_FILES['file_img1']['name']!=""){
$img1 = $_FILES['file_img1']['name'];
$fileElementName = 'file_img1';
$path = 'upload/';
$location = $path . $_FILES['file_img1']['name'];
move_uploaded_file($_FILES['file_img1']['tmp_name'], $location);
$str.='file1="$img1",';
}
.......
$sel="update tbl_job_schedule set
".$str."
status='schwork',
user_cmntdate=now(),
cmnt='".$_REQUEST['addcmnt']."' where clientname='".$rw['clientname']."' and username='".$_SESSION['user']."' and jobdate='".$_SESSION['strmonth']."-".$_REQUEST['dt']."-".$_SESSION['yy']."'";
mysql_query($sel) or die($sel);
}