ความคิดเห็นที่ 5
เคยลองเก็บไฟล์ในฟิลด์แบบ binary large object (BLOB) และ ชื่อไฟล์,นามสกุล ใน database หรือยังครับ ตอนเอาออกเช็ค session ไรเรียบร้อยตามต้องการ แล้วค่อย ออกเป็น stream หรือ binary แล้ว Response.ContentType เช็คตามชื่อไฟล์ หรื่อนามสกุลออกเลย ก็คล้ายๆกับโหลดไฟล์ปรกติ เช่น ไฟล์ PDF ตัว ContentType เป็น "Application/pdf" ตอนโหลดผ่าน IE acrobat readEr ก็ตั้งรับเลย
การทำแบบนี้ดีตรงที่จับต้องไฟล์ผ่าน directory ไม่ได้ กันการเข้าถึงได้ดีกว่า ไม่ต้องยุ่งกับ Server Directory permission แต่แบบนี้อาจยุ่งยากสักหน่อย อาจคุ้มค่าและเหมาะสำหรับบางงานนะครับ
Response.ContentType ที่ใช้บ่อย ๆๆๆ
นามสกุล "TXT", "TEXT", "JS", "VBS", "ASP", "CGI", "PL", "NFO", "ME", "DTD" ใช้ Response.ContentType = "text/plain"
นามสกุล "HTM", "HTML", "HTA", "HTX", "MHT" ใช้ Response.ContentType = "text/html"
นามสกุล "CSV" ใช้ Response.ContentType = "text/comma-separated-values"
นามสกุล "JS" ใช้ Response.ContentType = "text/javascript"
นามสกุล "CSS" ใช้ Response.ContentType = "text/css"
นามสกุล "PDF" ใช้ Response.ContentType = "application/pdf"
นามสกุล "RTF" ใช้ Response.ContentType = "application/rtf"
นามสกุล "XML", "XSL", "XSLT" ใช้ Response.ContentType = "text/xml"
นามสกุล "WPD" ใช้ Response.ContentType = "application/wordperfect"
นามสกุล "WRI" ใช้ Response.ContentType = "application/mswrite"
นามสกุล "XLS", "XLS3", "XLS4", "XLS5", "XLW" ใช้ Response.ContentType = "application/msexcel"
นามสกุล "DOC" ใช้ Response.ContentType = "application/msword"
นามสกุล "PPT","PPS" ใช้ Response.ContentType = "application/mspowerpoint"
'WAP/WML files นามสกุล "WML" ใช้ Response.ContentType = "text/vnd.wap.wml"
นามสกุล "WMLS" ใช้ Response.ContentType = "text/vnd.wap.wmlscript"
นามสกุล "WBMP" ใช้ Response.ContentType = "image/vnd.wap.wbmp"
นามสกุล "WMLC" ใช้ Response.ContentType = "application/vnd.wap.wmlc"
นามสกุล "WMLSC" ใช้ Response.ContentType = "application/vnd.wap.wmlscriptc"
'Images นามสกุล "GIF" ใช้ Response.ContentType = "image/gif"
นามสกุล "JPG", "JPE", "JPEG" ใช้ Response.ContentType = "image/jpeg"
นามสกุล "PNG" ใช้ Response.ContentType = "image/png"
นามสกุล "BMP" ใช้ Response.ContentType = "image/bmp"
นามสกุล "TIF","TIFF" ใช้ Response.ContentType = "image/tiff"
นามสกุล "AI","EPS","PS" ใช้ Response.ContentType = "application/postscript"
'Sound files นามสกุล "AU","SND" ใช้ Response.ContentType = "audio/basic"
นามสกุล "WAV" ใช้ Response.ContentType = "audio/wav"
นามสกุล "RA","RM","RAM" ใช้ Response.ContentType = "audio/x-pn-realaudio"
นามสกุล "MID","MIDI" ใช้ Response.ContentType = "audio/x-midi"
นามสกุล "MP3" ใช้ Response.ContentType = "audio/mp3"
นามสกุล "M3U" ใช้ Response.ContentType = "audio/m3u"
'Video/Multimedia files นามสกุล "ASF" ใช้ Response.ContentType = "video/x-ms-asf"
นามสกุล "AVI" ใช้ Response.ContentType = "video/avi"
นามสกุล "MPG","MPEG" ใช้ Response.ContentType = "video/mpeg"
นามสกุล "QT","MOV","QTVR" ใช้ Response.ContentType = "video/quicktime"
นามสกุล "SWA" ใช้ Response.ContentType = "application/x-director"
นามสกุล "SWF" ใช้ Response.ContentType = "application/x-shockwave-flash"
'Compressed/archives นามสกุล "ZIP" ใช้ Response.ContentType = "application/x-zip-compressed"
นามสกุล "GZ" ใช้ Response.ContentType = "application/x-gzip"
นามสกุล "RAR" ใช้ Response.ContentType = "application/x-rar-compressed"
'Miscellaneous นามสกุล "COM","EXE","DLL","OCX" ใช้ Response.ContentType = "application/octet-stream"
'Unknown (send as binary stream) นามสกุล "อื่นๆ " ใช้ Response.ContentType = "application/octet-stream"
;) มี idea ที่เคยทำแค่นี้ล่ะครับ คล้าย ๆ ท่าน C แต่ใช้ database ร่วม
จากคุณ :
deoinbox
- [
3 ก.พ. 52 13:15:16
A:125.24.223.217 X:
]
|
|
|