มีปัญหากับการ upload รูปภาพ ปัญหาคือ uploads แล้วติด Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied /
ปัญหาคือ uploads แล้วติด
Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied
/project/act_add_member.asp, line 22
*** หน้า form คือ ** member.asp
<%session("id")=1200100096579
Set Rs=Server.CreateObject("ADODB.Recordset")
SQL="Select * From sq_file Where sqp_id='1200100096579'"
Rs.Open Sql,conn,1,3
%>
<form action = "act_add_member.asp" method = "post" enctype="multipart/form-data">
<table width='80%' border=0 align=center cellpadding=1 cellspacing=1>
<tr>
<td bgcolor=#ffffff align=center> <Br>
<table width="402" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#eeeeee">
<td colspan="2" align="center"> <img src="file:///D|/all%20project/gift/picturs/xx.gif" width="13" height="16">
ÊÁѤÃÊÁÒªÔ¡ </td>
</tr>
<tr>
<td width="131" height="24"><font color="#000000" size="2">ชื่อ</font></td>
<td width="263"><font size="2">
<input name = name type = text id="name" value="<%=Rs("sq_name")%>" size="15" maxlength="25">
<font color="#FF0000">* </font></font></td>
</tr>
<tr>
<td><font size="2">รูปภาพfont></td>
<td><font size="2">
<INPUT name="blob" TYPE="file" class="input_button3" size="20">
</font></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type = submit value = "ADD" class="input_button3" >
<input name="reset" type = reset value = "Clear" class="input_button3">
</td>
</tr>
</table>
**** หน้ารับ ***** act_add_member.asp
<%
if uploaddata.Item("name").Item("value")="" or _
uploaddata.Item("blob").Item("value")="" then
response.write"<center><input type=button class=input_button3 value='¡¡ÃÍ¡¢éÍÁÙÅäÁè¤Ãº ¡ÅѺ仡ÃÍ¡¢éÍÁÙÅãËÁ!!' onClick='history.go(-1)' ></center>"
else
filename = uploaddata.item("blob").item("filename") '--ÍéÒ§¶Ö§ª×èͧ͢ ªèͧÃѺÊ觢éÍÁÙÅáÅéǵÒÁ´éÇ ¤èÒ value ËÃ×Í 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/student/"&filename_new))
uploadfile.write uploaddata.Item("blob").Item("value")
uploadfile.close
filename_new="image\student\"&filename_new
userid = session("id")
sql2 = "Select * from sq_file where sq_name='"&uploaddata.Item("name").Item("value")&"'"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open sql2, conn, 1,3
if (Rs1.EOF) Then
sql="select * from sq_file"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1,3
if rs.recordcount <> 0 then
rs.addnew
rs("sq_name")=uploaddata.Item("name").Item("value")
rs("path_pic")=filename_new
rs.Update
rs.close
conn.close
With Response
.Write "<br><br><table align=center width=400 cellspacing=0 cellpadding=0 bgcolor=#ff6600><tr><td>"
.Write "<table align=center border=0 width='100%' cellpadding=1 cellspacing=1>"
.Write "<tr><td bgcolor=#ffffcc align=center>"
.Write "<b>Status : </b> <IMG SRC=picture/icon_mini_register.gif >ºÑ¹·Ö¡¢éÍÁÙÅà¢éÒÊÙèÃкºàÃÕºÃéÍÂáÅéÇ "
.Write "</td></tr></table>"
.Write "</td></tr></table>"
End With
else
end if
else
With Response
.Write "<br><br><table align=center width=400 cellspacing=0 cellpadding=0 bgcolor=#ff6600><tr><td>"
.Write "<table align=center border=0 width='100%' cellpadding=1 cellspacing=1>"
.Write "<tr><td bgcolor=#ffffcc align=center>"
.Write "<b>Status : </b> ÃËÑʹÕéä´é·Ó¡ÒÃÊÁѤÃáÅéǤÃѺ"
.Write "</td></tr></table>"
.Write "</td></tr></table>"
End With
rs1.close
end if
end if
%>
*** ตัว upload **** getuploaddata.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
Array --
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))
Dictionary--
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 + 5
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 :
25 ส.ค. 2548 21:54:32
By :
mido22
View :
2559
Reply :
1
โหย ยาวจังขี้เกียจอ่าน
ผมว่าคงเกี่ยวกับการกำหนด การเข้าถึง folder ที่ใช้เก็บรูปครับ ต้องไปกำหนดให้ เป็นแบบอ่าน-เขียนได้ (ปกติจะเป็นแบบอ่านอย่างเดียว)
แต่ไม่แน่ใจนะครับว่า server เป็น linux หรือ windows แล้วจะกำหนดยังไง
ผมใช้ linux server ก็จะไปกำหนด permission ของ folder นั้นผ่านโปรแกรม FTP โดยกำหนดเป็น 777 ครับ
Date :
26 ส.ค. 2548 02:26:23
By :
prayat_multi
Load balance : Server 02