FTP คืออะไร? วิธีใช้ FTP อัพโหลดไฟล์บน Hosting ไทย 2026
FTP (File Transfer Protocol) คือโปรโตคอลมาตรฐานสำหรับการถ่ายโอนไฟล์ระหว่างคอมพิวเตอร์กับ server ผ่านเครือข่าย เจ้าของเว็บไซต์ใช้ FTP เพื่ออัพโหลดไฟล์ HTML, รูปภาพ, และไฟล์อื่นๆ ไปยัง hosting server
FTP (File Transfer Protocol) is the standard protocol for transferring files between computers and servers over a network. Website owners use FTP to upload HTML files, images, and other content to their hosting server.
FTP vs SFTP vs FTPS
มีโปรโตคอลการถ่ายโอนไฟล์หลายแบบที่ควรรู้จัก:
- FTP (Port 21): โปรโตคอลดั้งเดิม ส่งข้อมูลเป็น plain text ไม่มีการเข้ารหัส ไม่ปลอดภัยสำหรับข้อมูลสำคัญ
- FTPS (FTP Secure): FTP + SSL/TLS encryption มีความปลอดภัยมากกว่า FTP ธรรมดา
- SFTP (SSH File Transfer Protocol): ทำงานผ่าน SSH protocol ปลอดภัยสูงสุด รองรับโดย hosting ส่วนใหญ่
แนะนำ: ใช้ SFTP เสมอถ้า hosting รองรับ (ส่วนใหญ่ port 22) เพราะข้อมูล credentials และไฟล์ถูกเข้ารหัสทั้งหมด
Recommendation: Always use SFTP if your hosting supports it (usually port 22). All credentials and file transfers are fully encrypted.
ใช้ FileZilla เชื่อมต่อ FTP
FileZilla คือ FTP client ที่ฟรีและนิยมมากที่สุด รองรับ Windows, Mac, Linux
- Download FileZilla จาก filezilla-project.org
- เปิด FileZilla → กรอก Quickconnect bar ด้านบน:
Host: ftp.yourdomain.com หรือ ns1.hosting-server.com
Username: FTP username ที่ได้จาก hosting
Password: FTP password
Port: 21 (FTP) หรือ 22 (SFTP) - คลิก Quickconnect
- ฝั่งซ้าย = ไฟล์ในคอมพิวเตอร์, ฝั่งขวา = ไฟล์ใน server
- ลากไฟล์จากซ้ายไปขวาเพื่ออัพโหลด หรือจากขวาไปซ้ายเพื่อ download
FileZilla is the most popular free FTP client, supporting Windows, Mac, and Linux. Download from filezilla-project.org. Fill in the Quickconnect bar: Host (ftp.yourdomain.com), Username, Password, Port (21 for FTP, 22 for SFTP). Left panel = your computer, Right panel = server. Drag files from left to right to upload.
สร้าง FTP Account ใน DirectAdmin
- Login DirectAdmin → Extra Features → FTP Management
- คลิก Create FTP Account
- กรอก Username, Password และ Home Directory (โฟลเดอร์ที่ FTP account นี้เข้าถึงได้)
- คลิก Create
ควรสร้าง FTP account แยกสำหรับแต่ละ developer หรือ contractor และกำหนด Home Directory ให้จำกัดเฉพาะโฟลเดอร์ที่จำเป็น ป้องกันการเข้าถึงไฟล์อื่นโดยไม่ได้รับอนุญาต
File Permissions (chmod)
File permissions กำหนดว่าใครสามารถอ่าน เขียน หรือรันไฟล์ได้ ค่า permission ใน Linux/Unix ใช้ตัวเลข 3 หลัก:
- 755 (rwxr-xr-x): เหมาะสำหรับโฟลเดอร์ — owner รัน/แก้ไขได้, คนอื่นอ่านได้
- 644 (rw-r--r--): เหมาะสำหรับไฟล์ HTML/CSS/JS — owner แก้ไขได้, คนอื่นอ่านได้
- 600 (rw-------): เหมาะสำหรับไฟล์ config ที่มีรหัสผ่าน — owner อ่าน/แก้ไขได้เท่านั้น
- 777: ทุกคนทำได้ทุกอย่าง — อันตราย ห้ามใช้กับไฟล์สำคัญ
Common permissions: 755 = folders (owner can execute/write, others can read), 644 = HTML/CSS/JS files (owner can write, others can read), 600 = config files with passwords (owner only), 777 = everyone can do everything (dangerous — avoid for important files).
FTP Commands พื้นฐาน (Command Line)
ถ้าต้องการใช้ FTP ผ่าน command line:
ftp ftp.yourdomain.com # เชื่อมต่อ
ls # แสดงไฟล์
put file.html # อัพโหลดไฟล์
get file.html # download ไฟล์
bye # ตัดการเชื่อมต่อ
คำถามที่พบบ่อย (FAQ)
FTP password ลืมต้องทำอะไร?
เข้า DirectAdmin → FTP Management → แก้ไข account → เปลี่ยน password ใหม่ได้เลย ไม่ต้องติดต่อ support
อัพโหลดไฟล์ผ่าน FTP แล้วเว็บไม่อัพเดท ต้องทำอะไร?
ลอง hard refresh browser (Ctrl+Shift+R) ก่อน ถ้าใช้ Cloudflare หรือ CDN อาจต้องเคลียร์ cache ที่นั่นด้วย หรือรอ cache หมดอายุ
SFTP ต้องใช้ port อะไร?
SFTP ทำงานผ่าน SSH ใช้ port 22 โดยทั่วไป ต่างจาก FTP ที่ใช้ port 21 ใน FileZilla ให้เปลี่ยน port เป็น 22 และ protocol เป็น SFTP
ทำไม FTP เชื่อมต่อไม่ได้?
สาเหตุที่พบบ่อย: username/password ผิด, ไม่ได้เปิด FTP access, firewall บล็อก port 21, host ผิด ลอง passive mode ถ้าอยู่หลัง NAT/firewall