[PHP] ท่านใดพอมีแนวทาง การเขียน php ให้โหลดไฟล์ แบบต้องใส่ user pass ตามตัวอย่าง

เริ่มโดย konglpam, 10 พฤษภาคม 2017, 16:15:47

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

konglpam

อ้างถึงhttp://xxxx.com/get.php?username=xxthaixx&password=xx123xx&type=docx

ขอบคุณล่วงหน้าทุกๆคำตอบครับ :wanwan031:

konglpam

1
#1
1

Xilinx

http://stackoverflow.com/questions/2742654/using-php-download-file-from-a-given-url-by-passing-username-and-password-for-ht

แบบนี้ได้ไหมครับ

infamous

แค่คอนเซ็ปต์นะครับ ง่ายๆ


// retrieve params via cgi
$type=isset($_GET['type']) ? strtolower($_GET['type']) : NULL;
$usr=isset($_GET['username']) ? $_GET['username'] : NULL;
$pwd=isset($_GET['pass']) ? sh1($_GET['pwd'].$salt) : NULL;

$allowed_types = array('docs','xlsx','pdf');

// sql
$user = select * from user where username='{$usr}' and pass='{$pwd}'

if ($user && in_array($type, $allowed_types)) {
// document process
// header(type, params)
} else {
die("Woo! this user does not exist in our system");
}