 |
|
มีปัญหาคือ
ไม่สามารถ uploads ได้ติดตรงนี้คือ
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'MidB'
/project/uploads.asp, line 18
[
**หน้าส่ง"addpic.asp"***
<%id=request.querystring("sqp_id")%>
<form action="addpic_uploads.asp" method="post">
<input type="hidden" name="id" value=<%=id%>>
<table><tr>
<td align=right><div align="left"><font color="#000000" size="2" face="MS Sans Serif, Tahoma, sans-serif">
<strong>â»Ã´àÅ×Í¡ä¿ÅìÃÙ»:</strong></font></div></td>
<td><input type="file" name="blob" class=input_button2></td>
</tr>
<tr> <td><input type="submit" value="Upload" class=input_button2></td>
</tr></table>
--------------------------------------------------------------------------------------------------------------------------
**หน้ารับ"addpic_uploads.asp"***
<!-- #include file="uploads.asp"-->
<%
filename=uploaddata.Item("blob").Item("filename")
pos_filebegin=InStrRev(filename,"\")
pos_fileend=Len(filename)
filename_new=Mid(filename,pos_filebegin+1,pos_fileend-pos_filebegin)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set uploadfile=fs.CreateTextFile(Server.Mappath("image"&"/"&filename_new))
uploadfile.Write uploaddata.Item("image").Item("value")
uploadfile.Close
id=request.form("id")
set rs=server.createobject("ADODB.recordset")
sql="select * from sq_file where sqp_id='"&id&"'"
rs.open sql,conn,3,3
rs("path_pic")=filename_new
rs.Update%>
--------------------------------------------------------------------------------------------------------------------------
**ตัว uploads"uploads.asp"**
<%
Function TextToBinary(text)
For i=1 to Len(text)
character=Mid(text,i,1)
TextToBinary=TextToBinary & ChrB(Asc(character))
Next
End Function
Function BinaryToText(Binary)
BinaryToText=""
For i=1 to LenB(Binary)
character=MidB(Binary,i,1)
BinaryToText=BinaryToText & Chr(AscB(character))
Next
End Function
Set uploaddata=CreateObject("Scripting.Dictionary")
data=Request.BinaryRead(Request.TotalBytes)
posend=InStrB(1,data,TextToBinary(Chr(13)))
header=MidB(data,1,posend-1)
endheader=header&TextToBinary("_")
pos_header=1
pos_endheader=InStrB(1,data,endheader)
Do While pos_header<>pos_endheader
Set sub_uploaddata=CreateObject("Scripting.Dictionary")
pos_name=InStrB(pos_header,data,TextToBinary("name="))
pos_namebegin=pos_name+6
pos_nameend=InStrB(pos_namebegin,data,TextToBinary(Chr(34)))
name=BinaryToText(MidB(data,pos_namebegin,pos_nameend-pos_namebegin))
pos_file=InStrB(pos_nameend,data,TextToBinary("filename="))
enddata=InStrB(pos_nameend,data,header)
If (pos_file<>0)And(pos_file<enddata) Then
pos_filebegin=pos_file+10
pos_fileend=InStrB(pos_filebegin,data,TextToBinary(Chr(34)))
filename=BinaryToText(MidB(data,pos_filebegin,pos_fileend-pos_filebegin))
sub_uploaddata.Add "filename",filename
pos_content=InStrB(pos_fileend,data,TextToBinary("Content-Type:"))
pos_contentbegin=pos_content+14
pos_contentend=InStrB(pos_contentbegin,data,TextToBinary(Chr(13)))
contenttype=BinaryToText(MidB(data,pos_contentbegin,pos_contentend-pos_contentbegin))
sub_uploaddata.Add "contenttype",contenttype
pos_valuebegin=pos_contentend+4
pos_valueend=InStrB(pos_valuebegin,data,header)-2
Value=BinaryToText(MidB(data,pos_valuebegin,pos_valueend-pos_valuebegin))
sub_uploaddata.Add "value",value
Else
pos_valuebegin=pos_nameend+4
pos_valueend=InStrB(pos_valuebegin,data,header)-2
Value=BinaryToText(MidB(data,pos_valuebegin,pos_valueend-pos_valuebegin))
sub_uploaddata.Add "value",value
End If
uploaddata.Add name,sub_uploaddata
pos_header=InStrB(pos_header+LenB(header),data,header)
Loop
%>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
20 ส.ค. 2548 11:42:46 |
By :
mido |
View :
2370 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |