|
|
|
การเขียน code upload รูปครับชื่อถูกบันทึกลง db แต่ว่ารูปภาพไม่ได้ถูกเก็บไว้ใน folder |
|
|
|
|
|
|
|
คุณใช้ตัวแปรมั่วครับ
Code (PHP)
$fileUpload = $_POST["fileUpload"];
$uploads_dir = "../../uploads/";
$tmp_name = $_FILES["fileUpload"]["tmp_name"];
$name = $_FILES["fileUpload"]["name"];
if($name != '')
{
copy ( $tmp_name, $uploads_dir.$name );
//*** UPDATE Record ***//
$editSQL = "UPDATE picture";
$editSQL .=" SET photo = '".$name."' WHERE photo_id = '".$id."' ";
$result = mysql_query($editSQL);
echo "UPDATE picture SET photo = '".$fileUpload."' WHERE photo_id = '".$id."'";
}
|
|
|
|
|
Date :
2011-12-15 17:16:40 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูบทความการอัพโหลดครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
<a href="PageUploadToMySQL3.php">View files</a>
</body>
</html>
Go to : PHP Uploads Files To MySQL Database
|
|
|
|
|
Date :
2011-12-15 17:17:18 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileUpload = $_POST["fileUpload"];
$uploads_dir = "../../uploads/";
$tmp_name = $_FILES["fileUpload"]["tmp_name"];
$name = $_FILES["fileUpload"]["name"];
if($name != '')
{
copy ( $tmp_name, $uploads_dir.$name );
//*** UPDATE Record ***//
$editSQL = "UPDATE picture";
$editSQL .=" SET photo = '".$name."' WHERE photo_id = '".$id."' ";
$result = mysql_query($editSQL);
echo "UPDATE picture SET photo = '".$fileUpload."' WHERE photo_id = '".$id."'";
}
สามารถใช้ code นี้ได้หรอค่ะ
|
|
|
|
|
Date :
2011-12-15 17:20:09 |
By :
น้ำ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|