Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนหน่อยค๊าฟพอดี อัพรูปแก้ไข emotion ม่ะได้อ่ะคัฟ T_T



 

รบกวนหน่อยค๊าฟพอดี อัพรูปแก้ไข emotion ม่ะได้อ่ะคัฟ T_T

 



Topic : 104627



โพสกระทู้ ( 119 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



Code
<?php
/**
* admin emoticon
* author: mr.v automatic
*/

function page_emoticon_home() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
//--------------------------//
$output = "<div class=\"page\">\n";
$output .= $html->h("1", $adminlang->trans("Emoticon"));
if ($section == "add") {// add data--------------------------------------------------------
$output .= page_emoticon_add();
} elseif ($section == "edit") {// edit data--------------------------------------------------------
$output .= page_emoticon_edit();
} elseif ($section == "delete") {// delete data--------------------------------------------------------
$output .= page_emoticon_delete();
} else {// view data--------------------------------------------------------
$output .= "<p>".$html->a($adminlang->trans("Add"), "?page=$page&section=add")."</p>\n";
$sql = "select * from "._dbpre_."emoticon";
$rs = $db->execute($sql);
//loop show emoticons
$output .= "<form method=\"post\" action=\"?page=$page&section=delete\">\n";
$output .= "<table>\n";
$output .= "<tr>\n";
$output .= "<th>".$html->input("checkbox", "emo_id", "", array("onclick"=>"checkAll(this.form,'emo_id[]',this.checked)"))."</th>\n";
$output .= "<th>id</th>\n";
$output .= "<th>".$adminlang->trans("text")."</th>\n";
$output .= "<th>".$adminlang->trans("image")."</th>\n";
$output .= "<th></th>\n";
$output .= "</tr>\n";
while (!$rs->EOF) {
$output .= "<tr>\n";
$output .= "<td class=\"cell_checkbox\">".$html->input("checkbox", "emo_id[]", $rs->fields("emo_id"))."</td>\n";
$output .= "<td>".$rs->fields("emo_id")."</td>\n";
$output .= "<td>".$rs->fields("emo_txt")."</td>\n";
$output .= "<td>".$html->img("../".$rs->fields("emo_img"))."</td>\n";
$output .= "<td>".$html->a($adminlang->trans("edit"), "?page=$page&section=edit&emo_id=".$rs->fields("emo_id"))."</td>\n";
$output .= "</tr>\n";
$rs->movenext();
}
$output .= "</table>\n";
$output .= $html->input("submit", "btnact", $adminlang->trans("Delete selected"), array("onclick"=>"return confirm('".$adminlang->trans("Confirm delete?")."');"));
$output .= "</form>\n";
}
$output .= "</div>\n";
return $output;
}//page_emoticon_home

function page_emoticon_add() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
// add process-------------------------------------------------------------
if ($act == "do") {
$emotxt = form::postval("emotxt");
$emofile = form::fileval("emofile");
// check before add.--------------------------
if ($emotxt != null && $emofile != null) {
$emofile_name = $emofile['name'];
$emofile_size = $emofile['size'];
$emofile_type = $emofile['type'];//result image/jpeg, image/png, image/gif
$emofile_ext = files::showfileext($emofile_name, "lower");
$allow_add = false;
if (($emofile_ext == "jpg" || $emofile_ext == "jpeg") || $emofile_ext == "gif" || $emofile_ext == "png") {
//if ($emofile_size <= '20480') {
$allow_add = true;
//} else {
// You are uploading file size larger than we limit.
//}
} else {
$status = myhtml::displayerror("error_Please use file type as specified.");
}
} else {
$status = myhtml::displayerror("error_Please fill the form.");
}
// end check --------------------------
if ($allow_add == true) {
$last_emo_id = (mydb::get_last_id(_dbpre_."emoticon", "emo_id") != false ? mydb::get_last_id(_dbpre_."emoticon", "emo_id") : die("Db error admin-emoticon.php in add function."));
$emo_order = mydb::get_last_id(_dbpre_."emoticon", "emo_order");
$new_emofile_name = "emo-".$last_emo_id."-".tools::randompw("10").".".$emofile_ext;
$new_emo_path = "../".$cfg['site']['emoticon_path'];
//อัปโหลด
if (move_uploaded_file($emofile['tmp_name'], $new_emo_path.$new_emofile_name)) {
$rec = array();
$rec['emo_id'] = $last_emo_id;
$rec['emo_txt'] = psql($emotxt);
$rec['emo_img'] = str_replace("../", "", $new_emo_path).$new_emofile_name;
$rec['emo_order'] = $emo_order;
$db->autoexecute(_dbpre_."emoticon", $rec, 'INSERT');
if ($db->errormsg()) {
unlink($new_emo_path.$new_emofile_name);
$status = myhtml::displayerror("error_Database error.");
} else {
$status = myhtml::displaysuccess("admin_Add emoticon success.", "admin");
}
} else {
$status = myhtml::displayerror("error_Error, please try gain.");
}
}
}
// add process-------------------------------------------------------------
$output = $html->h("2", $adminlang->trans("Add"));
$output .= $html->div(@$status, array("class"=>"status-msg"));
$output .= "<form method=\"post\" action=\"?page=$page&section=$section&act=do\" enctype=\"multipart/form-data\">\n";
$output .= $html->div($adminlang->trans("from text:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("text", "emotxt", @$emotxt, array("size"=>"10"))." ".$html->span($adminlang->trans("text do not start with / (it is chat command)"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div($adminlang->trans("to image:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("file", "emofile")." ".$html->span($adminlang->trans("jpg, gif"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"form-name"))."\n";
$output .= $html->div($html->button("submit", "btnact","","submit"), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"clear"))."\n";
$output .= "</form>\n";
return $output;
}// page_emoticon_add

function page_emoticon_edit() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
// retrieve info from db
$emo_id = form::getval("emo_id");
$sql = "select * from "._dbpre_."emoticon where emo_id = ".psql($emo_id).";";
$rs = $db->execute($sql);
if (!$db->errormsg()) {
if (!$rs->EOF) {
$emotxt = $rs->fields("emo_txt");
$emoimg = $rs->fields("emo_img");
} else {
die("Non id match");
}
} else {
die("Db error while editing emoticon");
}
// edit process------------------------------------------------------------------
if ($act == "do") {
$emotxt = form::postval("emotxt");
$emofile = form::fileval("emofile");
// check before add.--------------------------
$allow_submit = false;
$need_upload = false;
if ($emotxt != null) {
if ($emofile['type'] != null) {
$emofile_name = $emofile['name'];
$emofile_size = $emofile['size'];
$emofile_type = $emofile['type'];//result image/jpeg, image/png, image/gif
$emofile_ext = files::showfileext($emofile_name, "lower");
if (($emofile_ext == "jpg" || $emofile_ext == "jpeg") || $emofile_ext == "gif" || $emofile_ext == "png") {
//if ($emofile_size <= '20480') {
$allow_submit = true;
$need_upload = true;
//} else {
// You are uploading file size larger than we limit.
//}
} else {
$status = myhtml::displayerror("error_Please use file type as specified.");
}
} else {
// no file upload
$allow_submit = true;
}
} else {
$status = myhtml::displayerror("error_Please fill the form.");
}
// end check --------------------------
//อัปโหลด
if ($need_upload == true) {
$new_emofile_name = "emo-".$emo_id."-".tools::randompw("10").".".$emofile_ext;
$new_emo_path = "../".$cfg['site']['emoticon_path'];
if (move_uploaded_file($emofile['tmp_name'], $new_emo_path.$new_emofile_name)) {
$allow_submit = true;
} else {
$allow_submit = false;
$status = myhtml::displayerror("error_Error, please try gain.");
}
}
// update db
if ($allow_submit == true) {
$old_emo_img = "../".$emoimg;
$rec = array();
$rec['emo_txt'] = psql($emotxt);
if ($need_upload == true) {
$rec['emo_img'] = str_replace("../", "", $new_emo_path).$new_emofile_name;
}
$db->autoexecute(_dbpre_."emoticon", $rec, 'UPDATE', 'emo_id = '.psql($emo_id).'');
if (!$db->errormsg()) {
if ($need_upload == true) {
@unlink($old_emo_img);
$emoimg = str_replace("../", "", $new_emo_path).$new_emofile_name;
} else {
$emoimg = $emoimg;
}
$status = myhtml::displaysuccess("admin_Edit emoticon success.", "admin");
} else {
@unlink($new_emo_path.$new_emofile_name);
$status = myhtml::displayerror("error_Database error.");
}
}
}
// edit process------------------------------------------------------------------
$output = $html->h("2", $adminlang->trans("Edit"));
$output .= $html->div(@$status, array("class"=>"status-msg"));
$output .= "<form method=\"post\" action=\"?page=$page&section=$section&emo_id=$emo_id&act=do\" enctype=\"multipart/form-data\">\n";
$output .= $html->div($adminlang->trans("from text:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("text", "emotxt", @$emotxt, array("size"=>"10"))." ".$html->span($adminlang->trans("text do not start with / (it is chat command)"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div($adminlang->trans("old image:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->img("../".$emoimg), array("class"=>"form-input"))."\n";
$output .= $html->div($adminlang->trans("to image:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("file", "emofile")." ".$html->span($adminlang->trans("jpg, gif"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"form-name"))."\n";
$output .= $html->div($html->button("submit", "btnact","","submit"), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"clear"))."\n";
$output .= "</form>\n";
return $output;
}// page_emoticon_edit

function page_emoticon_delete() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
$emo_id = form::postval("emo_id");
foreach ($emo_id as $id) {
$sql = "select * from "._dbpre_."emoticon where emo_id = ".psql($id)."";
$rs = $db->execute($sql);
if (!$db->errormsg()) {
while (!$rs->EOF) {
unlink("../".$rs->fields("emo_img"));
$db->execute("delete from "._dbpre_."emoticon where emo_id = ".psql($id)."");
if ($db->errormsg()) {die("DB error at ".$id);}
$rs->movenext();
}
} else {
die ("DB error while deleting emoticon.");
}
}
tool::redirect(_REFERER_);
}// page_emoticon_delete

?>

พอกดเลือกรูปแล้วกด อัพรูปมันขึ้น
Code
Warning: move_uploaded_file(../images/emo/emo-6-evedegaset.gif): failed to open stream: Permission denied in /home/akyinth/domains/aky.in.th/public_html/room/admin/admin-emoticon.php on line 88 Warning: move_uploaded_file(): Unable to move '/tmp/phpWSwoI2' to '../images/emo/emo-6-evedegaset.gif' in /home/akyinth/domains/aky.in.th/public_html/room/admin/admin-emoticon.php on line 88

มันขึ้นแบบนี้ เลยไปดูที่บรรทัด 88 ผมไม่รู้ว่าจะแก้ยังไงดีอ่ะคัฟ T_T โค้ดอยู่ด้านบน รบกวนหน่อยนะคัฟ



Tag : PHP, Ajax, jQuery, JAVA







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-01-15 13:04:36 By : ghosting View : 666 Reply : 2
 

 

No. 1



โพสกระทู้ ( 2,311 )
บทความ ( 1 )



สถานะออฟไลน์


Permission denied

เซ็ตโฟล์เดอร์ chmode เป็น 777 ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-01-15 13:38:20 By : arm8957
 


 

No. 2



โพสกระทู้ ( 119 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ขอบคุณมากๆคัฟ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-01-15 14:42:24 By : ghosting
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนหน่อยค๊าฟพอดี อัพรูปแก้ไข emotion ม่ะได้อ่ะคัฟ T_T
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่