|
|
|
[*help]--------- จาก PHP Multiple Upload & Multiple Resize to MySQL |
|
|
|
|
|
|
|
จากที่ผมไปอ่านเรื่อง PHP Multiple Upload & Multiple Resize to MySQL อ่ะครับ
ผมอยากทราบว่าตอนลบจะเขียนยังไงอ่ะครับ
ตอน Insert เขียนอย่างนี้อ่ะ
Code (PHP)
<?
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$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","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"][$i]."')";
$objQuery = mysql_query($strSQL);
}
}
?>
PHP Multiple Upload & Multiple Resize to MySQL
Tag : - - - -
|
|
|
|
|
|
Date :
2009-07-15 17:25:19 |
By :
pokultra |
View :
1203 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@unlink("MyResize/". $data["Thumbnails"]);
@unlink("MyResize/". $data["FilesName"]);
$data คือข้อมูลที่ select มาจาก table คงเขียนเองได้
|
|
|
|
|
Date :
2009-07-15 21:13:02 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|