※ 引述《chan15 (ChaN)》之銘言:
: <?php
: // 判斷以及Sql Injecttion部份先略過
: $a = $_POST['a'];
: $b = $_FILES['file']['name'];
:
: $sql = sprintf("UPDATE table SET a = %s, b = %s WHERE id = 1", $a, $b);
: mysql_query($sql) or die(mysql_error());
: ※ 發信站: 批踢踢實業坊(ptt.cc)
: ◆ From: 114.36.21.208
: 推 Jerr:直接用primary key當file name, move_uploaded_file() 11/17 14:15
: → chan15:您好,不是上傳的問題,是沒有上傳判定更新檔案欄位的問題 11/17 15:48
: → arrack:沒值不要update 不就好了... 11/17 18:03
: → chan15:update是一個字串,如果要判斷沒有不加入的話 11/17 22:17
: → chan15:那是不太可能的,5個file欄位就有120種組合 11/17 22:18
$ex=NULL;
if($a!=''){$ex[]=" a='$a'";}
if($b!=''){$ex[]=" b='$b'";}
if($c!=''){$ex[]=" c='$c'";}
if($d!=''){$ex[]=" d='$d'";}
if($e!=''){$ex[]=" e='$e'";}
if(is_array($ex){
$sql="update xxx set ".implode($ex,' , ')." where ...xxxx";
}else{
}
: 推 Jerr:所以用 if( !empty($_FILES['file']) ) 包起來 ? 11/18 10:07
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.28.51
※ 編輯: arrack 來自: 61.62.28.51 (11/19 10:20)