Car for Life

หมวดไฟฟ้าทั่วไป อิเล็กทรอนิกส์ คอมพิวเตอร์ => ห้องคอมพิวเตอร์ => SMF => ข้อความที่เริ่มโดย: Auto Car ที่ 08 พฤษภาคม 2021, 11:29:48

หัวข้อ: ทำอีกล่ะ ทำอัพโหลดภาพขึ้นserver
เริ่มหัวข้อโดย: Auto Car ที่ 08 พฤษภาคม 2021, 11:29:48
ทำอัพโหลดภาพขึ้นserver

1. โหลด script ไปก่อน Download พอดีต้นฉบับมันหายไปแล้ว ผมเอาไฟล์ไปยำมานิดหน่อย ไม่รู้มีปัญหาอะไรมั้ย แต่ไล่โค้ดแล้วน่าจะไม่มีปัญหาครับ

2. วางแผนก่อน ว่าจะเอาไฟล์ที่อัพโหลดไปเก็บที่ไหนบนเซิร์ฟ อ่ะ สมมุติเป็น http://www.f0nt.com/forum/ ก็แตกไฟล์ข้อ 1 ไปใส่ในนั้นเลย จากนั้นทำการ CHMOD 777 ให้กับโฟลเดอร์ต่อไปนี้
 2.1 http://www.f0nt.com/forum/upload/files/
 2.2 http://www.f0nt.com/forum/upload/files/images/
 2.3 http://www.f0nt.com/forum/upload/files/thumb/images/
 2.4 http://www.f0nt.com/forum/upload/files/flash/

3. เปิดไฟล์ http://www.f0nt.com/forum/upload/image_upload.php ขึ้นมา (ใช้ notepad ก็ได้) บรรทัดที่ 5-7 มี config อยู่...
โค๊ด: [Select]
$maxsize     = 500 * 1024; // ขนาด แก้ตรง 500 เป็นตัวอื่น ตอนนี้เป็น 500KB/รูป
$baseurl     = 'http://www.f0nt.com/forum/upload/files/'; //url ไปโฟลเดอร์ที่เก็บรูป  อย่าลืมปิดท้ายด้วย /
$basedir     = 'files/'; // สอดคล้องกับโฟลเดอร์ในสุดของ baseurl ด้านบน

แก้ให้เหมาะสมตามเครื่องเราซะ
$basedir ถ้ากลัวงง ไม่แนะนำให้แก้ ถ้าอยากแก้...

$basedir จะอ้างอิงที่อยู่จากไฟล์ image_upload.php ไปยังโฟลเดอร์เก็บไฟล์ (โฟลเดอร์ที่ด้านในมีโฟลเดอร์ images, thumb, flash) ถ้าเราย้ายไฟล์ image_upload.php ไปไว้ที่อื่น ก็ต้องแก้ $basedir ตามด้วย แต่ถ้าแตกไฟล์จาก zip แล้วอัพขึ้นเซิร์ฟโดยไม่ได้ย้าย หรือเปลี่ยนชื่อโฟลเดอร์ ก็ไม่เป็นไร

4. ลองเข้าไปที่ http://www.f0nt.com/forum/upload/image_upload.php แล้วอัพไฟล์ดู ถ้าอัพไม่ได้...
   4.1 เช็คให้แน่ใจว่าทำ CHMOD 777 ครบหมดทุกโฟลเดอร์แล้ว
   4.2 เช็คให้แน่ใจว่า $basedir ถูกต้อง

5. ถ้าอัพสำเร็จแล้ว ต่อไปเอามาไปฝังในหน้าตอบกระทู้ ... จากโฟลเดอร์ของ smf ให้เปิดไปที่ /Themes/default/Post.template.php (แบ็คอัพก่อนเผื่อความปลอดภัย)
ธีม Default
ไฟล์ ธีม Post.template.php
หา:
โค๊ด: [Select]
โค๊ด: You are not allowed to view links. Register or Login
// Finally, the submit buttons.
echo '
เพิ่มก่อนที่หา:
โค๊ด: [Select]
โค๊ด: You are not allowed to view links. Register or Login
// Upload Image
echo '
<tr>
<td></td>
<td><iframe src="UPLOADURL" width="550" height="60" frameborder="0"></iframe></td>
</tr>';

ตรง UPLOADURL คือ url ที่มาจากข้อ 3 (http://www.f0nt.com/forum/upload/image_upload.php)

เครดิต: http://www.f0nt.com/forum/index.php?topic=6525.825

ที่มา... http://pordoo.com/tip/upload-pictures-server/
หัวข้อ: Re: ทำอีกล่ะ ทำอัพโหลดภาพขึ้นserver
เริ่มหัวข้อโดย: Auto Car ที่ 08 พฤษภาคม 2021, 11:33:43
เอามาฝากเพื่อนๆ ครับ จากที่ผมประสบปัญหา บอร์ด SMF ไม่สามารถฝากรูปได้อัตโนมัติ เนื่องจากทางเว็บ upic.me ได้ยุติการให้บริการ แนะนำให้ลองใช้ imgbb ดูครับผม วิธีการ

1. ให้เปิดไฟล์ index.template.php

ค้นหา

โค๊ด: You are not allowed to view links. Register or Login
</body>
แทนที่
โค๊ด: You are not allowed to view links. Register or Login
<script type="text/javascript" src="http://radarurl.com/js/radarurl_widget.js"></script><script type="text/javascript">radarurl_call_radar_widgetv2({edition:"Dynamic",location:"rightbottom"})</script><noscript><a href="http://radarurl.com/">website statistics</a></noscript>
</body>

สร้างไฟล์ imgbb.js Copy ข้อความด้านล่างทั้งหมด แล้ว Save ชื่อไฟล์ imgbb.js แล้วสร้างโพลเดอร์ scripts นำไฟล์ไปไว้ในธีม default ครับผม

โค๊ด: You are not allowed to view links. Register or Login
// MOD Title: Simple Image Upload
// MOD Author: Sium < admin@imgbb.com > (N/A) http://imgbb.com/mod
// MOD Version: 2.0.0

if(typeof(imgbb_add_text)=='undefined')
{
    var imgbb_lang="en";
   
    var imgbb_add_text="Add image to post";
   
    var imgbb_style="padding:10px 0px 0px 0px;font-weight:bold;";
   
    var imgbb_skip_textarea=new RegExp("username_list|search|recipients|signature","i");

if(imgbb_lang=="en"){imgbb_lang="";}else if(imgbb_lang.indexOf(".")===-1){imgbb_lang =".";}if(window.location.hash){var imgbb_text;var imgbb_hash;if(window.name.indexOf("imgbb_")===-1){imgbb_text=window.name;imgbb_hash=window.location.hash.substring(1).split("_");}else{imgbb_text=window.location.hash.substring(1);imgbb_hash=window.name.split("_");}if(imgbb_text!="" && imgbb_hash.length>1){if(imgbb_hash[0]=="imgbb"){var imgbb_id=imgbb_hash[1];imgbb_text=decodeURIComponent(imgbb_text);if(imgbb_text.length>20){if(opener!=null && !opener.closed){var imgbb_area=opener.document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i  ){if(i==imgbb_id){var editor=false;if(typeof opener.smf_editorArray==='object'){for(var A in opener.smf_editorArray){if(opener.smf_editorArray[A].opt.sUniqueId==imgbb_area[i].id){opener.smf_editorArray[A].insertText(imgbb_text.replace(new RegExp("
",'g'),"<br />"));editor=true;}}}if(editor==false){imgbb_area[i].value=imgbb_area[i].value imgbb_text;}opener.focus();window.close();}}}}window.location.replace("//"   imgbb_lang   "imgbb.com/upload?mode=code&url="   encodeURIComponent(document.location.href));}}}function imgbb_insert(){var imgbb_area=document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i  ){if(imgbb_area[i].name && !imgbb_skip_textarea.test(imgbb_area[i].name)){var attr=imgbb_area[i].getAttribute('data-imgbb');if(attr!="true"){var imgbb_div=document.createElement('div');imgbb_div.setAttribute('class',"imgbb");var imgbb_a=document.createElement('a');imgbb_a.innerHTML=imgbb_add_text;imgbb_a.href="javascript:imgbb_upload(" i ");";var imgbb_bullet=document.createElement('span');imgbb_bullet.setAttribute('class',"imgbb_bullet");imgbb_bullet.innerHTML=" • ";imgbb_div.appendChild(imgbb_bullet);imgbb_div.appendChild(imgbb_a);imgbb_area[i].setAttribute('data-imgbb',"true");if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].parentNode.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].parentNode.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.parentNode.appendChild(imgbb_div);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && imgbb_area[i].nextElementSibling.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else{if(imgbb_area[i].nextSibling.nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else if(imgbb_area[i].nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else{imgbb_area[i].parentNode.appendChild(imgbb_div);}}}}}}function imgbb_upload(areaid){window.open("//"   imgbb_lang   "imgbb.com/upload?mode=smf&url="   encodeURIComponent(document.location.href),"imgbb_"   areaid,"resizable=yes,width=720,height=540");return void(0);}if(typeof(window.addEventListener)=='function'){window.addEventListener('DOMContentLoaded',imgbb_insert,false);window.addEventListener('load',imgbb_insert,false);}else if(typeof(window.attachEvent)=='function'){window.attachEvent('onload',imgbb_insert);}else{if(window.onload!=null){var old_onload=window.onload;window.onload=function(e){old_onload(e);imgbb_insert();};}else{window.onload=imgbb_insert;}}for(var i=1;i<12;i =2){setTimeout("imgbb_insert()",i*1000);}imgbb_insert();}
หัวข้อ: Re: ทำอีกล่ะ ทำอัพโหลดภาพขึ้นserver
เริ่มหัวข้อโดย: Auto Car ที่ 08 พฤษภาคม 2021, 11:44:09
อัพโหลดรูปเข้า upic.me

ที่ /public_html/Themes/default
ไฟล์ Post.template.php

find:

โค๊ด: You are not allowed to view links. Register or Login
// Finally, the submit buttons.
echo '

Add After:

โค๊ด: You are not allowed to view links. Register or Login
<script type="text/javascript" src="http://upic.me/js/embedupload.js"></script>
<script type="text/javascript">
upic_target = document.postmodify.message;
upic_type = "bbthumb";
upic_buttoncss += "color:#000000;";
</script>

upic_target => จะให้เอา code ไปแปะที่ช่องไหน
upic_type => รูปแบบ code ที่แปะ มี htmlfull / htmlthumb / bbfull / bbthumb (ถ้าไม่ระบุ จะถือว่าเป็น bbthumb ครับ)
upic_buttoncss => css เสริมสำหรับข้อความในปุ่ม เผื่ออยากแก้สีแก้รูปแบบ ใส่ไปได้เลยครับ (การใส่สี รองรับ code แบบ #abcdef เท่านั้นนะครับ)
//htmlthumb,htmlfull ใช้ไม่ได้กับบอร์ด smf (บอร์ด smf ใช้bbcode)


ส่วน uploadprogress จะมีประมาณนี้ครับ

โค๊ด: You are not allowed to view links. Register or Login
<style type="text/css">
#upic_uploader{}
#upic_uploadprogress{}
.progressWrapper{margin-top:5px;}
.progressContainer{border-bottom:1px dotted #ddd;padding:2px;}
.progressName{text-align:left;color:black;margin-left:2px;float:left;}
.progressBarStatus{color:#666;text-align:right;margin:1px 1px 0 0;font-size:9px;}
.red{border:solid 1px #B50000;background-color:#FFEBEB;}
.green{border:solid 1px #DDF0DD;background-color:#EBFFEB;}
.blue{border:solid 1px #CEE2F2;background-color:#F0F5FF;}
.progressBarInProgress,.progressBarComplete,.progressBarError{clear:both;font-size:0;width:0%;height:2px;background-color:blue;margin-top:4px;}
.progressBarComplete{width:100%;background-color:green;visibility:hidden;}
.progressBarError{width:100%;background-color:red;visibility:hidden;}
</style>
สามารถ copy code ด้านบนไปแก้ไข แล้วใส่ต่อจาก script ได้เลยครับ


สำหรับ SMF 2.0 ขึ้นไปครับ รองรับการทำงานของ WYSIWYG editor เรียบร้อย

โค๊ด: You are not allowed to view links. Register or Login
<script type="text/javascript" src="http://upic.me/js/embedupload.js"></script>
<script type="text/javascript">
upic_target = document.postmodify.message;
upic_type = "bbthumb";
upic_buttoncss  = "color:#000000;";
upic_buttontext = "Select Images <span class=\"buttonSmall\">(2 MB Max)</span>";
 
function upic_custom(urlshow, urlfull, urlthumb) {
if (oEditorHandle_message.bRichTextEnabled) {
oEditorHandle_message.insertText("<a href=\"" + urlshow + "\"><img src=\"" + urlthumb + "\" border=\"0\"></a>");
} else {
upic_target.value += "[url="+urlshow+"][img]"+urlthumb+"[/img][/url]";
}
}
</script>

credit: http://www.icez.net/blog/721/quick-upic-me-upload-button

ที่มา http://pordoo.com/tip/upic-me/
หัวข้อ: Re: ทำอีกล่ะ ทำอัพโหลดภาพขึ้นserver
เริ่มหัวข้อโดย: Auto Car ที่ 08 พฤษภาคม 2021, 11:50:09
  สคริปต์ใส่โฆษณา
http://pordoo.com/mod/mod-smf-affiliate/
https://adgroupszone.blogspot.com/2021/04/mod-smf.html

https://drive.google.com/file/d/1pT-praO8OzFdOl8eLf1KaywejizXg1HJ/edit