|
|
|
พี่ครับทำตัวอัพโลหดไฟล์แต่มันแจ้งเออเรอว่า Invalid procedure call or argument: 'AscB' |
|
|
|
|
|
|
|
พี่ครับผมทำตัวอัพโหลดมาอ่ะครับ จะทำตัวอัพโหลดแบบหลายๆ พาท แต่มันแจ้งเออเรอว่า Invalid procedure call or argument: 'AscB'
มันเป็นที่อะไรหรอครับ แต่ถ้าอับไฟล์เดียวได้นะครับ อีกอย่างผมไม่ได้ใช้ Component นะครับ ทางผู้ดูแลเขาไม่ให้ใช้ครับ
Code (ASP)
<!--#include file="userheader.asp"-->
<!--#include file="usermenu.asp"-->
<td class="f2">
<script language="JavaScript">
function submits()
{
if (document.buying.txtbook.value=="")
{
alert('ใส่รายละเอียดหนังสือด้วย');
document.buying.txtbook.focus();
return false;
}
if (document.buying.file1.value=="")
{
alert('เลือกรูปภาพด้วย');
document.buying.file1.focus();
return false;
}
document.buying.submit();
}
</script>
<form method="post" action="buying.asp" enctype="multipart/form-data" name="buying" onsubmit="return submits()">
<script language="JavaScript">
function showPreview(ele)
{
document.buying.imgAvatar.src=ele.value;
}
</script>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
รายละเอียดหนังสือ
</td>
<td>
<textarea name="txtbook" rows="5" cols="50"></textarea>
</td>
</tr>
<tr>
<TD colspan="2"><img id="imgAvatar"></td>
</tr>
<tr>
<TD>รูป</td>
<TD><input type="file" name="file1" onchange="showPreview(this)"></td>
</tr>
<tr>
<TD>เอกสารแนบ</td>
<TD><input type="file" name="file2"></td>
</tr>
<tr>
<TD colspan="2"><input type="submit" value="ตกลง"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<!--#include file="footer.asp"-->
Upload Code (ASP)
<!--#include file="../connect.asp" -->
<!--#include file="upload.asp" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
</head>
<%
len1=Len(request("url"))-InstrRev(request("url"),"/")
pathinfo=Server.mappath(Request.ServerVariables("PATH_INFO"))
pathEnd = Len(pathinfo)-len1
filepath=left(pathinfo,pathEnd) & "buy/"
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
other_name = UploadRequest.Item("txtbook").Item("Value")
'****************** file1 ******************
filepathname = UploadRequest.Item("file1").Item("FileName")
if filepathname <> "" then
filename = lcase(Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")))
'response.write(filename & "<br>")
'response.write(len1 & "<br>")
response.write(filepathname & "<br>")
'response.write(other_name)
'response.write(filepath & "<br>")
value = UploadRequest.Item("file1").Item("Value")
'response.write(UploadRequest.Item("file1").Item("Value") & "<br>")
'response.write(value & "<br>")
limitSize = 200000 * 1024 ' 2000 kByte
if lenB(value) > limitSize then
response.write "<b>File ใหญ่เกิน " & _
formatNumber(limitSize / 1024) & _
" kB คลิก Back กลับไปเลือกใหม่"
response.end
end if
if Instr(filename,".jpg")<>0 then
ty=".jpg"
ElseIf Instr(filename,".jpeg")<>0 Then
ty=".jpeg"
ElseIf Instr(filename,".gif")<>0 Then
ty=".gif"
ElseIf Instr(filename,".png")<>0 Then
ty=".png"
else
%>
<p align="center"><font color="#FF0000">อนุญาติให้ Upload เฉพาะ .jpg, .jpeg, .gif, .png เท่านั้น</font></p>
<p align="center"><a href="javascript:history.back();">กลับไปแก้ไข</a></p>
<%
response.end
end if
if lenB(value) = 0 then
%>
<p align="center"><font color="#FF0000">ไม่มีไฟล์นี้</font></p>
<p align="center"><a href="javascript:history.back();">กลับไปแก้ไข</a></p>
<%
response.end
end if
Dim dmyt
dmyt=Day(Now()) & "-" & Month(Now()) &"-" & Year(Now()) & "-" & Hour(Now()) & "." & Minute(Now()) & "." & Second(Now())
file1=dmyt & "_" & filename
'-------------------- upload to server ------------------------
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set fileObj = ScriptObject.CreateTextFile(filepath & file1)
Dim i
i=0
For i = 1 to LenB(value)
fileObj.Write chr(AscB(MidB(value,i,1)))
'response.write(fileObj)
Next
Session("a")=file1
fileObj.Close
end if
'************************Upload File 2 *************************************************
filepathname2=UploadRequest.Item("file2").item("FileName")
if filepathname2 <> "" then
filename2 = lcase(Right(filepathname2,Len(filepathname2)-InstrRev(filepathname2,"\")))
'response.write(filename2 & "<br>")
'response.write(len1 & "<br>")
response.write(filepathname2 & "<br>")
'response.write(other_name)
'response.write(filepath & "<br>")
value2 = UploadRequest.Item("file2").Item("Value")
'response.write(UploadRequest.Item("file1").Item("Value") & "<br>")
'response.write(value & "<br>")
limitSize = 200000 * 1024 ' 2000 kByte
if lenB(value2) > limitSize then
response.write "<b>File ใหญ่เกิน " & _
formatNumber(limitSize / 1024) & _
" kB คลิก Back กลับไปเลือกใหม่"
response.end
end if
if Instr(filename2,".pdf")<>0 then
ty=".pdf"
ElseIf Instr(filename2,".doc")<>0 Then
ty=".doc"
else
%>
<p align="center"><font color="#FF0000">อนุญาติให้ Upload เฉพาะ .pdf, .doc เท่านั้น</font></p>
<p align="center"><a href="javascript:history.back();">กลับไปแก้ไข</a></p>
<%
response.end
end if
if lenB(value2) = 0 then
%>
<p align="center"><font color="#FF0000">ไม่มีไฟล์นี้</font></p>
<p align="center"><a href="javascript:history.back();">กลับไปแก้ไข</a></p>
<%
response.end
end if
file2=dmyt & "_" & filename2
'-------------------- upload to server ------------------------
Set ScriptObject2 = Server.CreateObject("Scripting.FileSystemObject")
Set fileObj2 = ScriptObject2.CreateTextFile(filepath & file2)
Dim j
j=0
For j = 1 to LenB(value2)
fileObj2.Write chr(AscB(MidB(value,j,1)))
'response.write(fileObj)
Next
Session("b")=file2
fileObj2.Close
Else
Session("b")="-"
End If
'*** Insert Record ***'
Dim d,sql,rr,s
d=Date()
strSQL = ""
strSQL = strSQL &"INSERT INTO book(bdetail,bpic,bfile,bdate,of_username,statuss) "
strSQL = strSQL &"VALUES ('" & other_name & "','"& Session("a") &"','" & Session("b") & "','"& d &"','" & Session("user") & "','0')"
'response.write(strSQL)
Set rec = con.Execute(strSQL)
Response.Write ("<script>window.location='book.asp';</script>")
%>
Tag : ASP, Ms SQL Server 2008, JavaScript
|
|
|
|
|
|
Date :
2012-06-05 10:54:13 |
By :
Clamore |
View :
1523 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ Component ชื่ออะไรครับ
|
|
|
|
|
Date :
2012-06-05 12:03:43 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|