|
 |
|
ผมสร้างฟอร์มอัพโหลดรูปและข้อความคอมเม้นแบบนี้ถูกหรือป่าวคับรบกวนพี่ๆ ช่วยดูให้หน่อยคับ |
|
 |
|
|
 |
 |
|
ดูตัวอย่างจาก phpUploadResizeToMySQL ครับแต่ก็ยังไปต่อไม่ค่อยถูกครับ
เลยเอาโค้ดหน้า phpUploadResizeToMySQL2.php มาให้ดูกันเลยครับว่าผมต้องแก้ไขยังไงครับ
phpUploadResizeToMySQL 1.php
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<div align="center"><form name="form1" method="post" action="phpMultiUploadResizeToMySQL2.php" enctype="multipart/form-data">
<input type="file" name="fileUpload[]"><br>
<label>
<textarea name="textarea[]" cols="50" rows="5" id="textarea1"></textarea>
</label>
<br>
<br>
<input type="file" name="fileUpload[]"><br>
<label>
<textarea name="textarea[]" cols="50" rows="5" id="textarea2"></textarea>
</label>
<br>
<br>
<input type="file" name="fileUpload[]"><br>
<label>
<textarea name="textarea[]" cols="50" rows="5"></textarea>
</label>
<br>
<br>
<input type="file" name="fileUpload[]"><br>
<label>
<textarea name="textarea[]" cols="50" rows="5"></textarea>
</label>
<br>
<br>
<input type="file" name="fileUpload[]"><br>
<label>
<textarea name="textarea[]" cols="50" rows="5"></textarea>
</label>
<br>
<br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
phpUploadResizeToMySQL 2.php
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
($i=0;$i<count($_FILES["textarea[]"]["text"]);$i++)
{
if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"][$i];
copy($_FILES["fileUpload"]["tmp_name"][$i],"MyResize/".$_FILES["fileUpload"]["name"][$i]);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"MyResize/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("zeed");
$strSQL = "INSERT INTO files ";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"][$i]."')";
$objQuery = mysql_query($strSQL);
}
}
?>
<a href="phpMultiUploadResizeToMySQL3.php">View files</a>
</body>
</html>
อันนี้ละครับที่ไปต่อไม่ถูกครับ ผมมันเด็กอ่อนหัดเองครับต้องรบกวนพี่ๆ ละครับCode (PHP)
Code
[code][/code]
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-10-20 16:01:14 |
By :
jason111 |
View :
1006 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ฟอร์มที่ใช้รับค่ารูป ก่อทำเป็น ลูบด้วยสิครับ แล้วส่งตัวแปล hidden มาลูบค่อมคำสั่งอัพโหลด
ตามจำนวนจริงที่ รับมา
ถ้าทำแบบตัวอย่างแล้วจะรู้ได้ไงว่ารับค่ามามีเท่าไหร่
|
 |
 |
 |
 |
Date :
2009-10-20 16:51:57 |
By :
ดร |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|