 |
|
ผมลองเขียนโค้ดให้มัน อัพโหลดรูปภาพลงแฟ้ม กับเก็บพาธเอาไว้ในฐานข้อมูล
เวลาที่รันแล้วนี่ จะ error ครับ แต่ในโฟลเดอร์ที่เก็บรูป มีรูปอยู่0 byte เหมือนกับว่ามัน
พยายามจะเขียนลง แต่ทำไม่ได้
อ.บอกว่ามันน่าจะเกี่ยวกับ read only แต่เวลาที่ผมคลิกเอา read only ออก แล้วปิดไป พอเรียก property ขึ้น
มาใหม่ มันก็ยังมีอยู่อ่ะครับ แก้ไม่ได้
ทั้งๆที่ชื่อ user ก็เป็น admin นะครับ
ใครรู้วิธี set ช่วยบอกด้วยครับ
ขอบคุณฮ้าบบบ
add_product.asp+++++++++++++++++++++++++
<!-- #include file="include.asp"-->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<form action="act_add_product.asp" method="post" enctype="multipart/form-data" name="form1">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="16%"> </td>
<td width="27%"> </td>
<td width="31%"> </td>
<td width="26%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="40"> </td>
<td>ÃËÑÊÊÔ¹¤éÒ</td>
<td><div align="left"><font size="2">
<input name = product_id type = text id="product_id2" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
</font></div></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>ª×èÍÊÔ¹¤éÒ</td>
<td><font size="2">
<input name = product_name type = text id="product_name6" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>ÃÒÂÅÐàÍÕ´</td>
<td><font size="2">
<textarea name = product_detail cols = 60 rows = 7 id="textarea"></textarea>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>ÃÙ»ÀÒ¾</td>
<td><font size="2">
<INPUT name="blob" TYPE="file" class="input_button3" size="30">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>¡ÅØèÁ</td>
<td><font size="2">
<%
Sql="Select * From group_product"
Set Rs1=conn.execute(sql)
%>
<select name="select" >
<option>Select Group Product</option>
<%while Not Rs1.EOF%>
<option value=<% =Rs1("group_product_id")%>>
<% =Rs1("group_product")%>
</option>
<%
Rs1.MoveNext
wend
rs1.close
%>
</select>
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>¨Ó¹Ç¹µèÓÊØ´</td>
<td><font size="2">
<input name = product_stock_min type = text id="product_stock_min" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>¨Ó¹Ç¹ÊÙ§ÊØ´</td>
<td><font size="2">
<input name = product_stock_max type = text id="product_stock_max" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>¨Ó¹Ç¹·Õèá¹Ð¹Ó</td>
<td><font size="2">
<input name = product_stock_advise type = text id="product_stock_advise2" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>ÃÐÂÐàÇÅÒÃѺ»ÃСѹ</td>
<td><font size="2">
<input name = product_guarantee type = text id="product_guarantee" onKeyPress="return keyCheck(event, this)" size="30" maxlength="10">
<br>
<br>
</font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input name="submit" type = submit value = "ºÑ¹·Ö¡¢éÍÁÙÅ" class="input_button3" >
<input name="reset" type = reset value = "ź¢éÍÁÙÅ" class="input_button3"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
act_add_product.asp++++++++++++++++++++++++++++++
<!--#include file="getuploaddata.asp"-->
<!-- #include file="include.asp"--><head>
<style>
<!--
a{text-decoration:none}
//-->
</style>
</head>
<%
if uploaddata.Item("product_id").Item("value")="" or _
uploaddata.Item("product_name").Item("value")="" or _
uploaddata.Item("product_detail").Item("value")="" or _
uploaddata.Item("blob").Item("value")="" or _
uploaddata.Item("select").Item("value")="" or _
uploaddata.Item("product_stock_min").Item("value")="" or _
uploaddata.Item("product_stock_max").Item("value")="" or _
uploaddata.Item("product_stock_advise").Item("value")="" or _
uploaddata.Item("product_guarantee").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("file/"&filename_new))
uploadfile.write uploaddata.Item("blob").Item("value")
uploadfile.close
filename_new="file\"&filename_new
userid = session("uname")
sql2 = "Select * from product where product_id='"&uploaddata.Item("product_id").Item("value")&"'"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open sql2, conn, 1,3
if (Rs1.EOF) Then
sql="select * from product"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1,3
if rs.recordcount <> 0 then
rs.addnew
rs("product_id")=uploaddata.Item("product_id").Item("value")
rs("product_name")=uploaddata.Item("product_name").Item("value")
rs("product_detail")=uploaddata.Item("product_detail").Item("value")
rs("product_pics")=filename_new
rs("product_stock_min")=uploaddata.Item("product_stock_min").Item("value")
rs("product_stock_max")=uploaddata.Item("product_stock_max").Item("value")
rs("product_stock_advise")=uploaddata.Item("product_stock_advise").Item("value")
rs("product_guarantee")=uploaddata.Item("product_guarantee").Item("value")
rs.Update
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=picturs/icon_mini_register.gif >ºÑ¹·Ö¡¢éÍÁÙÅà¢éÒÊÙèÃкºàÃÕºÃéÍÂáÅéÇ "
.Write "</td></tr></table>"
.Write "</td></tr></table>"
End With
rs.close
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
%>
<%
'-- ¿Ñ§¤ìªÑè¹à»ÅÕè¹ ¢éͤÇÒÁ à»ç¹ ¢éÍÁÙÅ亹ÒÃÕ --
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
'-- ¡Ó˹´¡ÒÃãªé Dictionary ·ÓãËéà¡çº¢éÍÁÙÅä´éÁÒ¡¤ÅéÒ¡Ѻ 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")
'--µÑ´ª×èÍ (ª×è͵ÑÇá»Ã¢Í§ªèͧ) ªèͧ¡ÃÍ¡¢éÍÁÙŧ·Ø¡ÃٻẺ àªè¹ textbox radio combobox à»ç¹µé¹ --
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
'---¢éÍÁÙÅà»ç¹ª¹Ô´ä¿ÅìÍѾâËÅ´ ãËé·Ó¡ÒõѴª×èÍä¿ÅìÍÍ¡ÁÒ (ª×èÍä¿Åìà»ç¹ Value ¢Í§µÑÇÍѾâËÅ´ä¿Åì)--
pos_filebegin = pos_file + 10
pos_fileend = InstrB(pos_filebegin,data,TextToBinary(chr(34)))
filename = BinaryToText(MidB(data,pos_filebegin,pos_fileend - pos_filebegin))
'--à¡çº¢éÍÁÙŪ×èÍä¿ÅäÇéã¹Íͺà¨ç¤ Dictionary--
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))
'--à¡çº¢éÍÁÙÅ ª¹Ô´¢Í§ä¿Åì·ÕèÍѾâËÅ´ (Content - Type) ã¹Íͺà¨ç¤ 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))
'--à¡çº¢éÍÁÙÅÀÒÂã¹ä¿ÅìÃÙ»ÀÒ¾ ŧã¹Íͺà¨ç¤ Dictionary--
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))
'--à¡çº¢éÍÁÙÅÀÒÂã¹ä¿Åì·ÑèÇä» Å§ã¹Íͺà¨ç¤ Dictionary--
sub_uploaddata.add "value",value
end if
'-- à¡çº¢éÍÁÙÅ·Ñé§ËÁ´Å§ã¹ Dictionary ª×èÍ uploaddata--
uploaddata.add name,sub_uploaddata
'--à»ÅÕè¹µÓáË¹è§ Header ä»Âѧ¢éÍÁÙŶѴä»(¶éÒËÒ¡ÁÕ) â´Â·Ó¡ÒÃǹÅÙ»àªç¤à§×è͹ä¢--
pos_header = InstrB(pos_header+LenB(header),data,header)
loop
%>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2 พ.ย. 2547 10:34:56 |
By :
gototon |
View :
3973 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |