|
 |
|
upload file ติดนิดหน่อย ทำไงดีหว่า ช่วยหน่อยดู code ให้หน่อยน่ะครับ ติดปัญหา |
|
 |
|
|
 |
 |
|
Code (PHP)
<html>
<head>
<title>Add Edit Delete</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("tot");
if($_POST["hdnCmd"] == "Add" || copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
$strSQL = "INSERT INTO project ";
$strSQL .="(number,type,customer,host,FilesName) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddnumber"]."','".$_POST["txtAddtype"]."' ";
$strSQL .=",'".$_POST["txtAddcustomer"]."' ";
$strSQL .=",'".$_POST["txtAddhost"]."' ";
$strSQL .=",'".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
}
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE project SET ";
$strSQL .="number = '".$_POST["txtEditnumber"]."' ";
$strSQL .=",type = '".$_POST["txtEdittype"]."' ";
$strSQL .=",customer = '".$_POST["txtEditcustomer"]."' ";
$strSQL .=",host = '".$_POST["txtEdithost"]."' ";
$strSQL .="WHERE number = '".$_POST["hdnEditnumber"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
}
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM project ";
$strSQL .="WHERE number = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
}
$strSQL = "SELECT * FROM project";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>" enctype="multipart/form-data">
<input type="hidden" name="hdnCmd" value="">
<table width="100" cellpadding=0 cellspacing=0 border="1">
<tr>
<th width="100"> <div align="center">หมายเลขวงจร</div></th>
<th width="100"> <div align="center">ประเภทวงจรเช่า </div></th>
<th width="10"> <div align="center">ลูกค้า </div></th>
<th width="10"> <div align="center">host </div></th>
<th width="150"> <div align="center">Files Name</div></th>
<th width="50"> <div align="center">Edit </div></th>
<th width="50"> <div align="center">Delete </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["number"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><div align="center">
<input type="text" name="txtEditnumber" size="5" value="<?=$objResult["number"];?>">
<input type="hidden" name="hdnEditnumber" size="10" value="<?=$objResult["number"];?>">
</div></td>
<td><input type="text" name="txtEdittype" size="30" value="<?=$objResult["type"];?>"></td>
<td><input type="text" name="txtEditcustomer" size="30" value="<?=$objResult["customer"];?>"></td>
<td><div align="center"><input type="text" name="txtEdithost" size="10" value="<?=$objResult["host"];?>"></div></td>
<td><center><a href="myfile/<?=$objResult["FilesName"];?>"><?=$objResult["FilesName"];?></a></center></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><div align="center"><?=$objResult["number"];?></div></td>
<td><?=$objResult["type"];?></td>
<td><?=$objResult["customer"];?></td>
<td><div align="center"><?=$objResult["host"];?></div></td>
<td><center><a href="myfile/<?=$objResult["FilesName"];?>"><?=$objResult["FilesName"];?></a></center></td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["number"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["number"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<tr>
<td><div align="center"><input type="text" name="txtAddnumber" size="30"></div></td>
<td><input type="text" name="txtAddtype" size="20"></td>
<td><input type="text" name="txtAddcustomer" size="20"></td>
<td><div align="center"><input type="text" name="txtAddhost" size="30"></div></td>
<td colspan="2" align="right"><div align="center">
<td><center><a href="myfile/<?=$objResult["FilesName"];?>"><?=$objResult["FilesName"];?></a></center></td>
</table >
<input type="file" name="filUpload"><br>
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</form>
<?
mysql_close($objConnect);
?>
</body>
</html>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-05-14 22:37:49 |
By :
NOMO |
View :
761 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่ upload file ไปยัง myfile ครับ ไม่รู้แก้ตรงไหนครับ
|
 |
 |
 |
 |
Date :
2010-05-14 23:28:59 |
By :
PISTOLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|