|
 |
|
สอบถาม การใช้ uploadify ไม่เข้าฐานข้อมูล และ Resize ภาพไม่เข้า folder ครับ งง |
|
 |
|
|
 |
 |
|
จากโค้ดครับ ภาพไม่เข้าฐานข้อมูล และภาพที่รีไซต์ ไม่เข้าไปในโฟลเดอร์ครับ
Code (PHP)
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
//$targetFolder = 'uploads'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
include('db_conn.inc.php');
$nameFile = $_FILES['Filedata']['name'];
/*$targetPath = $targetFolder;
$targetFile = $targetFolder . '/' . $_FILES['Filedata']['name'];*/
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
//move_uploaded_file($tempFile,$targetFile);
$new_image = 'resize_'.iconv('UTF-8','TIS-620',$nameFile);
$new_image_sql = 'resize_'.$nameFile;
$size_src = GetimageSize($tempFile);
$images_ori = ImageCreateFromJPEG($tempFile);
$width_src = ImagesX($images_ori);
$height_src = ImagesY($images_ori);
if($width_src>$height_src)//แนวนอน
{
$width_new = 800;
$height_new = round($width_new*$size_src[1]/$size_src[0]);//$size_src[1]=height,$size_src[0]=width
$images_ori = ImageCreateFromJPEG($tempFile);
$width_src = ImagesX($images_ori);
$height_src = ImagesY($images_ori);
$images_fin = ImageCreateTrueColor($width_new, $height_new);
ImageCopyResampled($images_fin,$images_ori,0,0,0,0,$width_new+1,$height_new+1,$width_src,$height_src);
ImageJPEG($images_fin,'uploads/'.$new_image);
ImageDestroy($images_ori);
ImageDestroy($images_fin);
//Insert record
$strSQL = 'insert into tb_test_pic (name_pic) values ('.$new_image_sql.')';
$qrySQL = mysql_query($strSQL)or die(mysql_error());
}
else
{
$height_new = 800;
$width_new = round($height_new*$size_src[0]/$size_src[1]);//$size_src[1]=height,$size_src[0]=width
$images_ori = ImageCreateFromJPEG($tempFile);
$width_src = ImagesX($images_ori);
$height_src = ImagesY($images_ori);
$images_fin = ImageCreateTrueColor($width_new, $height_new);
ImageCopyResampled($images_fin,$images_ori,0,0,0,0,$width_new+1,$height_new+1,$width_src,$height_src);
ImageJPEG($images_fin,'uploads/'.$new_image);
ImageDestroy($images_ori);
ImageDestroy($images_fin);
//Insert record
$strSQL = 'insert into tb_test_pic (name_pic) values ('.$new_image_sql.')';
$qrySQL = mysql_query($strSQL)or die(mysql_error());
}
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>
Tag : PHP, MySQL, Ajax, jQuery

|
ประวัติการแก้ไข 2014-09-23 11:25:22
|
 |
 |
 |
 |
Date :
2014-09-23 11:21:31 |
By :
angelkiller9 |
View :
736 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo ไล่ Step ดูครับ ว่ามันเข้า Case ไหนบ้าง
|
 |
 |
 |
 |
Date :
2014-09-23 14:35:06 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|