|
|
|
multiple upload ด้วย ajax ทำแล้วไม่อัพขึ้นฐานข้อมูลอ่ะค่ะช่วยดูให้หน่อยนะคะ |
|
|
|
|
|
|
|
Code (PHP)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Uploadify scriptData Sample</title>
<link rel="stylesheet" href="uploadify/uploadify.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#fileUpload2").fileUpload({
'uploader': 'uploadify/uploader.swf',
'cancelImg': 'uploadify/cancel.png',
'script': 'uploadify/upload.php',
'folder': 'MyResize',
'multi': true,
'buttonText': 'Select Files',
'checkScript': 'uploadify/check.php',
'displayData': 'speed',
'simUploadLimit': 2
});
});
</script>
</head>
<body>
<fieldset style="border: 1px solid #CDCDCD; padding: 8px; padding-bottom:0px; margin: 8px 0">
<legend><strong>Uploadify - Single and Multiple Sample</strong></legend>
<h2>Multiple File Upload</h2>
<p>checkScript, buttonText, simulataneous upload limit</p>
<div id="fileUpload2">You have a problem with your javascript</div>
<a href="javascript:$('#fileUpload2').fileUploadStart()">Start Upload</a> | <a href="javascript:$('#fileUpload2').fileUploadClearQueue()">Clear Queue</a>
<hr width=100% size="1" color="" align="center">
</fieldset>
</body>
</html>
Code (upload.php)
<?
//ทำ resize รูป
for($i=0;$i<count($_FILES["Filedata"]["name"]);$i++)
{
if(trim($_FILES["Filedata"]["tmp_name"][$i]) != "")
{
$images = $_FILES["Filedata"]["tmp_name"][$i];
$new_images = "Thumbnails_".$_FILES["Filedata"]["name"][$i];
copy($_FILES["Filedata"]["tmp_name"][$i],"../MyResize/".$_FILES["Filedata"]["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 and Upload Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("gallery");
$strSQL = "INSERT INTO picture ";
$strSQL .="(Thumbnails,PicName,album_id) VALUES ('".$new_images."','".$_FILES["Filedata"]["name"][$i]."','$album_id')";
$objQuery = mysql_query($strSQL);
}
}
?>
Tag : PHP
|
ประวัติการแก้ไข 2010-09-30 21:44:06 2010-09-30 21:45:08 2010-09-30 21:45:42 2010-09-30 21:46:56
|
|
|
|
|
Date :
2010-09-30 21:40:30 |
By :
nongjar |
View :
1430 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ชื่อตัวแปรถูกหรือเปล่าครับ กับค่าที่ส่งมา
|
|
|
|
|
Date :
2010-10-01 06:32:08 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|