|
|
|
ใครพอจะมี code uploadify upload รูปภาพหลายภาพและให้มัน resize หน่อยครับ รบกวนขอตัวอย่างหน่อยครับ |
|
|
|
|
|
|
|
multi_upload
<html>
<head>
<title>Multible Upload & Resize</title>
</head>
<script language="javascript">
function fncCreateElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
myLine.value++;
// Create input file
var myElement2 = document.createElement('input');
myElement2.setAttribute('type',"file");
myElement2.setAttribute('name',"fileUpload"+myLine.value);
myElement2.setAttribute('id',"fil"+myLine.value);
mySpan.appendChild(myElement2);
// Create <br>
var myElement3 = document.createElement('<br>');
myElement3.setAttribute('id',"br"+myLine.value);
mySpan.appendChild(myElement3);
}
function fncDeleteElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
if(myLine.value > 1 )
{
// Remove input file
var deleteFile = document.getElementById("fil"+myLine.value);
mySpan.removeChild(deleteFile);
// Remove <br>
var deleteBr = document.getElementById("br"+myLine.value);
mySpan.removeChild(deleteBr);
myLine.value--;
}
}
</script>
<body>
<form action="multi_upload1.php" method="post" name="form1" enctype="multipart/form-data">
<input type="file" name="fileUpload1">
<input name="btnCreate" type="button" value="+" onClick="JavaScript:fncCreateElement();">
<input name="btnDelete" type="button" value="-" onClick="JavaScript:fncDeleteElement();"><br>
<span id="mySpan"></span>
<input name="hdnLine" type="hidden" value="1">
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
multi_upload1
<?php ob_start(); ?>
<html>
<head>
<title>Multible Upload & Resize</title>
</head>
<body>
<?php
$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/db_main.mdb"));
for($j=1;$j<=(int)($_POST["hdnLine"]);$j++)
{
if($_FILES["fileUpload".$j]["name"] != "")
{
$sql = "select * from count";
$objRec = $strConn->Execute($sql);
$i = $objRec->Fields["num"]->Value + 1 ;
$sql = "update count set num=$i";
$strConn->Execute($sql);
$s_pic = "Thumbnails_".$i."_".$_FILES["fileUpload".$j]["name"];
$l_pic = $i."_".$_FILES["fileUpload".$j]["name"];
$sql = "insert into picture (s_picture,l_picture) values ('$s_pic','$l_pic')";
$strConn->Execute($sql);
$images = $_FILES["fileUpload".$j]["tmp_name"];
$new_images = "Thumbnails_".$i."_".$_FILES["fileUpload".$j]["name"];
copy($_FILES["fileUpload".$j]["tmp_name"],"MyResize/".$i."_".$_FILES["fileUpload".$j]["name"]);
$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/thumbnails/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
}
$strConn->Close();
$strConn = null;
header("Location: multi_slide.php");
?>
</body>
</html>
<?php ob_end_flush() ; ?>
|
|
|
|
|
Date :
2011-01-26 14:05:02 |
By :
lightkung |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|