|
|
|
ขอโค้ดอัฟโหลดไฟล์รูปภาพ กับโค้ดโชว์รูปภาพ ภาษาASP.VBscript |
|
|
|
|
|
|
|
จากโปรเจ็คเก่าโคด
message.asp
<%
If (Cint(Request.QueryString("mode")) = 1) Then
%>
<script language="JavaScript">
function addname()
{
document.upload.destination.value = document.upload.destination.value + document.upload.member.options[document.upload.member.selectedIndex].value + "; "
}
function cleartxt()
{
document.upload.destination.value = ""
}
function validate(){
if (document.upload.detail.value=="") {
alert("กรุณาป้อน คำอธิบายของ file..!");
document.upload.detail.focus();
return false;
}
if (document.upload.file.value=="") {
alert("กรุณาเลือก File ที่ต้องการ upload..!");
document.upload.file.focus();
return false;
}
if (document.upload.destination.value=="") {
alert("กรุณาเลือกชื่อผู้รับ!");
document.upload.destination.focus();
return false;
}
if (confirm("คุณต้องการส่ง file ที่คุณเลือกหรือไม่?")) {
return true;
} else {
return false;
}
} //redirect function
</script>
<form name="upload" action="sent.asp" method="post" enctype="multipart/form-data" onsubmit="return validate();">
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr>
<td class=line_ colspan=5></td>
</tr>
<tr>
<td colspan=5 height=1></td>
</tr>
<tr>
<td class=linel rowspan=6><img src="images/dot_linel.gif" border=0></td>
<td width=1 rowspan=6></td>
<td class=barhead style="vertical-align: middle" height=24>
<table id=table29 cellspacing=0 cellpadding=0 width="100%" border=0>
<tr>
<td style="vertical-align: middle" align="left" width="20"><img src="images/newmail.gif" border=0></td>
<td style="vertical-align: middle" width="100">
<h4>ส่งเอกสาร</h4>
</td>
<td> </td>
<td width="30"><a href="message.asp"><img src="images/personmail.gif"></a></td>
<td width="120"><a href="message.asp"><b>กล่องเอกสารส่วนตัว</b></a></td>
</tr>
</table>
</td>
<td height=1 rowspan=6></td>
<td class=linel rowspan=6><img src="images/dot_linel.gif" border=0></td>
</tr>
<tr>
<td class=line_></td>
</tr>
<tr>
<td>
<table cellspacing=0 cellpadding="5" width="100%" border="0">
<tr valign="top">
<td>
<table width="100%" cellspacing="0" cellpadding="3">
<tr valign="top">
<td width="60"><b>ส่งถึง:</b></td>
<td><input type="text" name="destination" size="30" readonly><input type="button" name="clear" value="ล้าง" onclick="cleartxt()"></td>
</tr>
<tr>
<td><b>คำอธิบาย:</b></td>
<td><input type="text" name="detail" size="30"></td>
</tr>
<tr>
<td><b>ชื่อเอกสาร:</b></td>
<td><input type="file" name="file"></td>
</tr>
<tr>
<td colspan="2"><font color="#FF0000">* ขนาดไฟล์ไม่เกิน 10 Mbytes</font></td>
</tr>
<tr height="30">
<td align="center" colspan="2">
<input type="submit" name="b_sent" value="ส่งเอกสาร">
<input type="reset" name="clr" value="ล้างข้อมูล">
<input type="button" name="cancel" value="ยกเลิก" onclick="javascript: history.go(-1)">
</td>
</tr>
</table>
</td>
<td width="24"><img src="images/leftarrow.gif"></td>
<td width="230" align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/border_top.gif" width="230" height="6"></td>
</tr>
<tr>
<td background="images/border_bg2.gif" align="center">
<h4>ส่งถึงสมาชิก</h4>
</td>
</tr>
<tr>
<td><img src="images/border_mid.gif" width="230" height="13"></td>
</tr>
<tr>
<td bgcolor="#c8c8c8" style="padding-left: 1px; padding-right: 1px;">
<table bgcolor="#f9f9f9" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table width="140" border="0" cellpadding="0" cellspacing="0">
<tr height="25">
<td align="center">
<select name="member" size="25" onclick="addname()">
<%
Set RSsec = Conn.Execute("Select * From [GOVSERV_SECTION] Where [SECTION_STATUS]=1 Order By [DIVISION_ID], [SECTION_ID]")
Set RSmember = Conn.Execute("Select [GOVSERV_PEOPLE].[GS_ID], [GOVSERV_PEOPLE].[GS_NAME], [GOVSERV_POSITION].[POSITION_SNAME], [GOVSERV_DIVISION].[DIVISION_SNAME] From [GOVSERV_PEOPLE] Inner Join [GOVSERV_POSITION] On [GOVSERV_PEOPLE].[POSITION_ID] = [GOVSERV_POSITION].[POSITION_ID] Inner Join [GOVSERV_DIVISION] On [GOVSERV_PEOPLE].[DIVISION_ID] = [GOVSERV_DIVISION].[DIVISION_ID] Order By [GOVSERV_POSITION].[POSITION_PIORITY], [GOVSERV_PEOPLE].[DIVISION_ID], [GOVSERV_PEOPLE].[GS_CODE]")
Do While Not RSsec.Eof
Response.Write "<option value='"& RSsec("SECTION_SNAME") &"'>กล่องเอกสารกลาง - "& RSsec("SECTION_SNAME") &"</option>"& vbLf
RSsec.MoveNext
Loop
RSsec.Close
Set RSsec = Nothing
Do While Not RSmember.Eof
'If (Not IsNull( RSmember("POSITION_SNAME"))) Then
'Response.Write "<option value='"& RSmember("GS_NAME") &"'>["& RSmember("POSITION_SNAME") &"] "& RSmember("GS_NAME") &"</option>"& vbLf
'Else
Response.Write "<option value='"& RSmember("GS_NAME") &"'>"& RSmember("DIVISION_SNAME") & " - " & RSmember("GS_NAME") &"</option>"& vbLf
'End if
RSmember.MoveNext
Loop
RSmember.Close
Set RSmember = Nothing
%>
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="images/border_bottom.gif" width="230" height="5"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class=line_></td>
</tr>
</table>
</form>
<%
Else
%>
<form name="box" method="post" action="delfile.asp">
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr>
<td class=line_ colspan=5></td>
</tr>
<tr>
<td colspan=5 height=1></td>
</tr>
<tr>
<td class=linel rowspan=6><img src="images/dot_linel.gif" border=0></td>
<td width=1 rowspan=6></td>
<td class=barhead style="vertical-align: middle" height=24>
<table cellspacing=0 cellpadding=0 width="100%" border="0">
<tr>
<td style="vertical-align: middle" align="left" width="30"><img src="images/personmail.gif" border=0></td>
<td style="vertical-align: middle" width="120">
<h4>กล่องเอกสารส่วนตัว</h4>
</td>
<td> </td>
<td width="20"><a href="message.asp?mode=1"><img src="images/newmail.gif"></a></td>
<td width="60"><a href="message.asp?mode=1"><b>ส่งเอกสาร</b></a></td>
<td width="20"><input type="image" src="images/delmail.gif"></td>
<td width="70"><a href="javascript: document.box.submit();"><b>ลบเอกสาร</b></td>
</tr>
</table>
</td>
<td height=1 rowspan=6></td>
<td class=linel rowspan=6><img src="images/dot_linel.gif" border=0></td>
</tr>
<tr>
<td class=line_></td>
</tr>
<tr>
<td>
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr bgcolor="#F9EDFA">
<td width="5%" style="padding: 3px;"></td>
<td width="5%" align="center" style="padding: 3px;"><input type="checkbox" name="checkall" onclick="if (document.box.checkall.checked == true) for (i = 0; i < document.box.length; i++) {document.box.check[i].checked = true;} else for (i = 0; i < document.box.length; i++) {document.box.check[i].checked = false;}"></td>
<td width="45%" style="padding: 3px;"><b>ชื่อเอกสาร</b></td>
<td width="30%" style="padding: 3px;"><b>จาก</b></td>
<td width="15%" style="padding: 3px;"><b>วันที่</b></td>
</tr>
<%
Set RSdoc = Conn.Execute("Select [GOVSERV_DOCUMENT].*, [GOVSERV_PEOPLE].[GS_NAME], [GOVSERV_DIVISION].[DIVISION_SNAME] From [GOVSERV_DOCUMENT] Inner Join ([GOVSERV_PEOPLE] Inner Join [GOVSERV_DIVISION] On [GOVSERV_PEOPLE].[DIVISION_ID] = [GOVSERV_DIVISION].[DIVISION_ID]) On [GOVSERV_DOCUMENT].[DOCUMENT_SENDER] = [GOVSERV_PEOPLE].[GS_ID] Where [GOVSERV_DOCUMENT].[DOCUMENT_OWNER]="& Session("user") &" And [GOVSERV_DOCUMENT].[DOCUMENT_PUBLIC]=0 Order by [GOVSERV_DOCUMENT].[DOCUMENT_DATE] Desc")
If (Not RSdoc.eof And Not RSdoc.bof) Then
Do While Not Rsdoc.Eof
temp_ext = Split(RSdoc("DOCUMENT_FILE"), ".")
ext = LCase(temp_ext(UBound(temp_ext)))
Select Case ext
Case "doc", "docx"
ext_image = "icon_doc.gif"
Case "xls", "xlsx"
ext_image = "icon_xls.gif"
Case "vsd", "vsdx"
ext_image = "icon_vsd.gif"
Case "mdb"
ext_image = "icon_mdb.gif"
Case "ppt", "pptx"
ext_image = "icon_ppt.gif"
Case "gif", "png"
ext_image = "icon_gif.gif"
Case "jpg"
ext_image = "icon_jpg.gif"
Case "bmp"
ext_image = "icon_bmp.gif"
Case "pdf"
ext_image = "icon_pdf.gif"
Case "tif"
ext_image = "icon_tif.gif"
Case "zip"
ext_image = "icon_zip.gif"
Case "rar"
ext_image = "icon_rar.gif"
Case "mp3", "wma"
ext_image = "icon_mp3.gif"
Case "mpg", "wmv", "mp4", "avi"
ext_image = "icon_mpg.gif"
Case Else
ext_image = "icon_oth.gif"
End Select
Response.Write "<tr>"
Response.Write "<td class='line_' colspan='5'></td>"
Response.Write "</tr>"
If (RSdoc("DOCUMENT_READ") = True) Then
Response.Write "<tr>" & vbLf
Else
Response.Write "<tr bgcolor='#FFFFE0'>" & vblf
End If
Response.Write "<td align='center' style='padding: 3px;'><img src='images/"& ext_image &"'></td>" & vbLf
Response.Write "<td align='center' style='padding: 3px;'><input type='checkbox' name='check' value="& RSdoc("DOCUMENT_ID") &"></td>" & vblf
Response.Write "<td style='padding: 3px;'><a href='loadfile.asp?id="& RSdoc("DOCUMENT_ID") &"' target='_blank' title='"& RSdoc("DOCUMENT_FILE") &"'><b>"& RSdoc("DOCUMENT_DETAIL") &"</b></a></td>" & vblf
Response.Write "<td style='padding: 3px;'>"& RSdoc("DIVISION_SNAME")& " - " &RSdoc("GS_NAME") &"</td>" & vbLf
Response.Write "<td style='padding: 3px;'>"& day(RSdoc("DOCUMENT_DATE")) &"/"& month(RSdoc("DOCUMENT_DATE")) & "/"& Year(RSdoc("DOCUMENT_DATE")) &"</td>" & vblf
Response.Write "</tr>" & vbLf
RSdoc.MoveNext
Loop
Else
Response.Write "<tr>"
Response.Write "<td class='line_' colspan='5'></td>"
Response.Write "<tr height='25'>"
Response.Write "<td colspan='2'></td>"& vblf
Response.Write "<td colspan='3' style='padding: 3px;'><b>ไม่มีเอกสาร</b></td>"& vblf
Response.Write "</tr>"
End If
RSdoc.close
Set RSdoc = Nothing
%>
</table>
</td>
</tr>
<tr>
<td class=line_></td>
</tr>
</table>
</form>
<%
End If
%>
sent.asp
<!--#include file="include/inc_upload.asp"-->
<%
' Author Philippe Collignon
' Email [email protected]
' Credit ให้เขาด้วยนะครับกรุณาอย่าเอาออก
randomize
x = int(1 + (rnd * 999))
Response.Expires = 0
Response.Buffer = True
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
contentType = UploadRequest.Item("file").Item("ContentType")
filepathname = UploadRequest.Item("file").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
values = UploadRequest.Item("file").Item("Value")
detail = UploadRequest.Item("detail").Item("Value")
destination = UploadRequest.Item("destination").Item("Value")
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
FilePath = Server.MapPath("document") & "\[" & x &"]"& filename
Set MyFile = ScriptObject.CreateTextFile(FilePath)
For i = 1 to LenB(values)
MyFile.Write chr(AscB(MidB(values,i,1)))
Next
MyFile.Close
Response.Redirect "sentfile.asp?f="& filename &"&d="& detail &"&t="& destination &"&p="&"[" & x &"]"& filename
%>
|
|
|
|
|
Date :
2010-04-20 12:44:26 |
By :
tungman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอไฟล์ฐานข้อมูลด้วยกับไฟล์ inc_upload.asp ด้วยนะครับ ขอบคุณมากๆ
|
|
|
|
|
Date :
2010-05-11 09:39:28 |
By :
arta_u |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|