|
|
|
อยากทราบว่าถ้าเราจะ browse file หลายรูปทำไงคือจะแยกเก็บในข้อมูลให้อยู่คนละช่องกัน |
|
|
|
|
|
|
|
ผมก็อยากรู้
|
|
|
|
|
Date :
2011-05-07 11:07:39 |
By :
suchinee |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนผู้รู้ช่วยตอบหน่อย
|
|
|
|
|
Date :
2011-05-10 08:05:43 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
mysql_connect("localhost","root","root") or die (mysql_error());
mysql_select_db("mydatabase");
for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
{
if($_FILES["fileUpload".$i]["name"] != "")
{
if(copy($_FILES["fileUpload".$i]["tmp_name"],"thaicreate/".$_FILES["fileUpload".$i]["name"]))
{
$strSQL = "INSERT INTO gallery ";
$strSQL .="(GalleryName,Picture) VALUES ('".$_POST["txtGalleryName".$i]."','".$_FILES["fileUpload".$i]["name"]."')";
mysql_query($strSQL);
echo "Copy/Upload ".$_FILES["fileUpload".$i]["name"]." completed.<br>";
}
}
}
echo "<br><a href='php_multiple_upload3.php'>View file</a>";
mysql_close();
?>
</body>
</html>
Go to : PHP MySQL Upload File to MySQL Database - Multiple Dynamic CreateElement Input File Upload
|
|
|
|
|
Date :
2011-05-10 08:28:21 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณสำหรับคำตอบ
แต่GalleryName ของหนูทำไมมันไม่แอดลงฐานข้อมูลค่ะ
Code (PHP)
<table>
<tr>
<td bgcolor="#66CCFF" align="right" width="100"><font color="#000000" size="3" face="Arial, Helvetica, sans-serif">ภาพก่อนติดตั้ง:</font></td>
<td bgcolor="#66CCFF">
<input type="text" name="txtGalleryName1"><input type="file" name="fileUpload1"><br>
<input type="text" name="txtGalleryName2"><input type="file" name="fileUpload2"><br>
<input name="photo_before" type="hidden" value="4">
</td>
</tr>
</table>
อีกไฟล์
Code (PHP)
<?
mysql_connect("localhost","root","1234") or die (mysql_error());
mysql_select_db("market");
for($i=1;$i<=(int)($_POST["photo_before"]);$i++)
{
if($_FILES["fileUpload".$i]["name"] != "")
{
if(copy($_FILES["fileUpload".$i]["tmp_name"],"photo/".$_FILES["fileUpload".$i]["name"]))
{
$strSQL = "INSERT INTO tblphoto ";
$strSQL .="(galleryname,photo) VALUES ('".$_POST["txtGalleryName".$i]."','".$_FILES["fileUpload".$i]["name"]."')";
mysql_query($strSQL);
echo "Copy/Upload ".$_FILES["fileUpload".$i]["name"]." completed.<br>";
}
}
}
mysql_close();
?>
|
|
|
|
|
Date :
2011-05-11 08:10:37 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของผมให้มัน resize ด้วยนะครับ
Code (PHP)
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if($_FILES["fileUpload"]["name"][$i] != "")
{
if(copy($_FILES["fileUpload"]["tmp_name"][$i],"../myfile/".$_FILES["fileUpload"]["name"][$i])) //myfile คือ folder ที่จะเก็บรูปนะครับ
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = "new_".$_FILES["fileUpload"]["name"][$i];
//copy($_FILES["fileUpload"]["tmp_name"][$i],"../myfile/".$_FILES["fileUpload"]["name"][$i]); //myfile คือ folder ที่จะเก็บรูปนะครับ
$width=800; //*** 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,"../myfile/".$new_images); //myfile คือ folder ที่จะเก็บรูปนะครับ
ImageDestroy($images_orig);
ImageDestroy($images_fin);
//echo "Resize Successful.<br>";
$thai_y = date("Y")+543;
$thai_y = substr($thai_y,2,3);
$dd_code = date("mdyhjiz");
$uid = $thai_y.$dd_code;
$date=date("Y-m-d");
@mysql_query("INSERT INTO tb_upimg(upimg_id,upimg_title,upimg_file,upimg_newfile,upimg_dateup) VALUES ('".$uid."','".$_POST["upimg_title"]."','".$_FILES["fileUpload"]["name"][$i]."','".$new_images."','".$date."')");
//$sql = "INSERT INTO tb_upimg(upimg_id,upimg_title,upimg_file,upimg_newfile,upimg_dateup) VALUES ('".$uid."','".$_POST["upimg_title"]."','".$_FILES["fileUpload"]["name"][$i]."','".$new_images."','".$date."')";
//$result = mysql_query($sql);
print $sql;
}
}
}
//print $sql;
//$result=mysql_query($sql);
if(mysql_query){
echo "<div align=\"center\"><img src='../image/loading3.gif'></div>";
echo "<div style=\"color:red; font-size:1px; font-weight:bold; text-align:left; margin-left:350px;\">กรุณารอสักครู่..</div>";
echo "<meta http-equiv='refresh' content='2;url=หน้าpage หลังจากการ insert'>";
}
else{
print("<center>\n");
exceptionMSG("Incomplete");
print("</center>\n");
}
|
|
|
|
|
Date :
2011-05-11 08:39:20 |
By :
โปรแกรมเมอร์ฝึกหัด |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|