這是整個代碼在那裏我有一個問題上傳文件:有人能讓我知道如何超越這個錯誤嗎?
<?php
//get the value of the selected radio value from webpage1.html
$n=$_POST['company'];
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname;
?>
<html><head><title>web page1</title></head><body>
<?php
// logical selection for $n
if($n==1){
echo"You selected Company <font color=red>bhagis portal</font> <br>";
$dbname="bhagis_portal";
}
elseif($n==2){
echo"You selected Company <font color=red>bli portal</font> <br>";
$dbname="bliportal";
}
elseif($n==3){
echo"You selected Company <font color=red>m portal</font> <br>";
$dbname="m_portal";
}
else{
echo"You Selected Company <font color=red>vg portal</font> <br>";
$dbname="vg_portal";
}
$conn=mysql_connect($dbhost,$dbuser,$dbpass)or die("<strong class="highlight">Error</strong> connecting to MySQL");
mysql_select_db($dbname)or die(mysql_error());
$query="Select * from img_table";
$row=mysql_query($query)or die(mysql_error());
while($result=mysql_fetch_array($row)){
echo $result[0].") ";
echo "<img src=/".$dbname."/images/".$result[1]."><br>";
}
?>
<<strong class="highlight">form</strong> action="index_web_page2.php" method="post" enctype="multipart/form-data">
<input name="hiddenField" type="hidden" id="hiddenField" value="999999">
<input type="file" id="timesheet" name="timesheet"><br>
<input type="submit" name="cb_read" id="cb_read" value="Upload Timekeeping File">
<input type=reset name=reset value=clear></form>
<?php
$pic=$_file["timesheet"]["tmp_name"];
$destination='\xampp\htdocs\new'.'\\'.$dbname.'\images'.'\\'.$_files["timesheet"] ["tmp_name"];
move_uploaded_file($pic,$destination);
/* key code */
$query="insert into img_table(img_name) values('".$pic."')";
?>
</body>
</html>
該代碼具有先選擇5數據庫的能力......我想有圖像的輸出在第一,這將揭示它的輸出在瀏覽器...默認情況下,它並沒有被用戶上傳,但已經存在一個文件夾中(只有while循環語句中圖像標籤的路徑)。我現在的問題是,我不知道如何做到這一點兩兩件事:
1)如果用戶會上傳一些東西,它會自動轉移到$目的地
2)的最後上傳用戶將顯示太喜歡在while循環語句來完成
我會很欣賞你的解釋和幫助
,什麼是錯誤? – 2011-03-23 01:14:16