|
 |
|
อยากสอบถามเรื่องการ upload file image resize ใน browser IE ไม่ได้ รายละเอียดด้านในเลยครับ |
|
 |
|
|
 |
 |
|
ใน google chrome ใช้งานได้ปกติ แต่ใน IE มันไม่ยอม copy รูป ไปยัง folder ที่กำหนดเลยอะครับ
อยากทราบว่าเป็นเพราะสาเหตุอะไรหรอครับ..
*ไม่มี Error อะไรเกิดขึ้น
อันนี้ Form ธรรมดา
1.php
Code (PHP)
<form action="2.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input type="file" name="inFile" id="inFile" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
ส่วนนี้ใช้สำหรับ check
2.php
Code (PHP)
<?php
$path="MyResize/"; // folder ที่อยู่ของไฟล์
if($_FILES['inFile'][type]=="image/jpeg"){ // check ว่าใช้นามสกุล .jpg
$t=time(); // เวลาในปัจจุบัน
$newname ="$t.jpg"; // เอาเวลาปัจจุบันมาเก็บไว้ในตัวแปร $newname เพื่อไม่ให้ชื่อของรูปภาพซ้ำกัน
copy($_FILES["inFile"]["tmp_name"],"MyResize/".$newname);
$images = "MyResize/$newname"; // ตำแหน่งที่อยู่ของไฟล์รูปภาพขนาดใหญ่
$width=500; //*** ลดขนาดความกว้างของรูปภาพให้เหลือ 500px ***//
$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/".$newname); // ตำแหน่งที่อยู่ไฟล์รูปภาพขนาดเล็ก
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
?>
Tag : PHP

|
ประวัติการแก้ไข 2012-01-03 11:22:42
|
 |
 |
 |
 |
Date :
2012-01-03 11:21:22 |
By :
systemanalysis |
View :
1449 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
echo $_FILES['inFile'][type]
ออกมาดูครับ ie มันมี type ที่ต่างจากพวกอยู่อันนึง จำไม่ได้เหมือนกันว่าอะไร มันเลยไม่เข้า if นะ
|
 |
 |
 |
 |
Date :
2012-01-03 11:23:00 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ..ผมก็พึ่งรู้นะเนี่ยว่า type ไม่เหมือนกันแต่ละเบาร์เซอร์ - -
|
 |
 |
 |
 |
Date :
2012-01-03 11:25:55 |
By :
systemanalysis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
และก็ควรเขียนแบบนี้ $_FILES['inFile']['type'] ไม่ใช่แบบนี้ $_FILES['inFile'][type] เพราะแบบหลังนี้บาง server รันไม่ผ่านหรอกนะครับ
|
 |
 |
 |
 |
Date :
2012-01-03 16:18:56 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|