|
|
|
ทำให้ upload ไฟล์ เป็นภาษาไทย แก้ตรงไหน และทำไงครับ พอดี งง |
|
|
|
|
|
|
|
Code Upload (PHP)
<style>
<?php
include "class.resizepic.php";
$db = new mysqli("localhost", "root", "123456", "dbboard");
if(mysqli_connect_errno()) die("Connect Failed! :" . mysqli_connect_error());
mysql_query("SET NAMES UTF8");
if(isset($_POST['Submit'] ))
{
$num_file = count($_FILES['file']['name']);
$select = false;
$count = 0;
for($i = 0; $i < $num_file ; $i++)
{
if($_FILES['file']['error'][$i] != 0)
{
$count++;
continue;
}
if($_FILES['file']['name'][$i] != "")
{
$Filename = $_FILES['file']['name'][$i];
$type = $_FILES['file']['type'][$i];
// .gif, .png, .jpg, .zip, .docx, .pdf, .doc, .swf, .rar
$time = time() * microtime();
if ( $type == "image/gif") {$Filename = $time.".gif"; $pic_type = 'GIF'; }
else if ($type == "image/png") {$Filename = $time.".png"; $pic_type = 'PNG'; }
else if (($type == "image/jpg") or ($type=="image/jpeg") or ($type == "image/pjpeg")) {$Filename = $time.".jpg"; $pic_type = 'JPG'; }
else if ($type == "application/octet-stream") {$Filename = $time.".zip"; $pic_type = false;}
else if ($type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {$Filename = $time.".docx"; $pic_type = false;}
else if ($type == "application/pdf") {$Filename = $time.".pdf"; $pic_type = false;}
else if ($type == "application/msword") {$Filename = $time.".doc"; $pic_type = false;}
else if ($type == "application/x-shockwave-flash") {$Filename = $time.".swf"; $pic_type = false;}
else if ($type == "application/octet-stream") {$Filename = $time.".rar"; $pic_type = false;}
if(move_uploaded_file($_FILES['file']['tmp_name'][$i], 'fileUpload/'.$Filename)){
if($pic_type){
$original_image = "fileUpload/" . $Filename ;
$pic_size = getimagesize($original_image);
$desired_width = 250 ;
$per_div = abs($desired_width - $pic_size[0]) * 100 / $pic_size[0];
$desired_height = $pic_size[0] > $desired_width ? $pic_size[1] - floor( $pic_size[1] * $per_div / 100) : $pic_size[1] + floor( $pic_size[1] * $per_div / 100);
$image = new hft_image($original_image);
$image->resize($desired_width, $desired_height, '0');
$image->output_resized("fileUpload/".$Filename, "JPG");
}
$sql = $db->query("INSERT INTO files (file_name) VALUES ('{$Filename}') ");
if($sql)
{
echo "<H3><CENTER><br><br><br><br><br><img src='images/thumbsup.png' width='256px' height='161px'></CENTER></H3>";
echo "<META HTTP-EQUIV=refresh CONTENT=\"1; page_admin.php\">";
$upload_true = true;
}else{
echo "<H3>ERROR:Can not Upload</H3>";
}
}
}else{
$count++;
}
}
}
?>
Tag : PHP, Windows
|
ประวัติการแก้ไข 2015-10-03 18:38:53
|
|
|
|
|
Date :
2015-10-03 13:14:30 |
By :
NuItMaster |
View :
904 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แนะนำให้เปลี่ยนชื่อเป็นภาาษอังกฤษแทนครับ หรือไม่ใช้พวก datetime มาเป็นชื่อครับ ไม่งั้นปัญหาไม่จบครับ
|
|
|
|
|
Date :
2015-10-03 19:39:41 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือ ยังไงครับ พอดีไม่รู้เรื่องการ upload เท่าไหร่ครับ
|
|
|
|
|
Date :
2015-10-03 19:45:36 |
By :
NuItMaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|