Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > ASP > ASP Forum > ดู code ให้หน่อยครับ ช่วยดูให้หน่อยครับว่าทำไมมันถึง upload รูปไม่ได้ครับ



 

ดู code ให้หน่อยครับ ช่วยดูให้หน่อยครับว่าทำไมมันถึง upload รูปไม่ได้ครับ

 



Topic : 003733

Guest




ช่วยดูให้หน่อยครับว่าทำไมมันถึง upload รูปไม่ได้ครับ

และอยากรู้วิธีในการลบรูปภาพใน Folder (image) ด้วยครับว่าจะทำยังไงดี

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<%@ codepage=874%>
<%Response.Buffer = True
Response.Clear%>
<%Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
if PosEnd = 0 then
Response.Write "<b>Form was submitted with no ENCTYPE=""multipart/form-data""</b><br>"
Response.Write "Please correct the form attributes and try again."
Response.End
end if
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)

Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))

Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")

Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)

If PosFile<>0 AND (PosFile<PosBound) Then

PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
FileName = Mid(FileName,InStrRev(FileName,"\")+1)

UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))

ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType

PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = FileName
ValueBeg = PosBeg-1
ValueLen = PosEnd-Posbeg
Else

Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
ValueBeg = 0
ValueEnd = 0
End If

UploadControl.Add "Value" , Value
UploadControl.Add "ValueBeg" , ValueBeg
UploadControl.Add "ValueLen" , ValueLen

UploadRequest.Add name, UploadControl

BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub

Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function

Function UploadFormRequest(name)
on error resume next
if UploadRequest.Item(name) then
UploadFormRequest = UploadRequest.Item(name).Item("Value")
end if
End Function%>

<%RequestBin = Request.BinaryRead(Request.TotalBytes)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin

AF_keys = UploadRequest.Keys

Dim imgFileName(), imgMaxFileSize
Redim imgFileName(UploadRequest.Count)

imgMaxFileSize = 50*1024

for AF_i = 0 to UploadRequest.Count - 1
AF_curKey = AF_keys(AF_i)
if UploadRequest.Item(AF_curKey).Item("FileName") <> "" then
AF_valueLen = UploadRequest.Item(AF_curKey).Item("ValueLen")
select case Right(UploadRequest.Item(AF_curKey).Item("FileName"), 3)
case "jpg","JPG"
if AF_valueLen = 0 then
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(AF_curPath) & UploadRequest.Item(AF_curKey).Item("FileName") & "<br>"
Response.Write "File does not exists or is empty.<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
Response.End
end if

if AF_valueLen > imgMaxFileSize then
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(AF_curPath) & UploadRequest.Item(AF_curKey).Item("FileName") & "<br>"
Response.Write "File size (" & FormatNumber(AF_valueLen,0) & " Bytes) is more than max file size (" & FormatNumber(imgMaxFileSize,0) & " Bytes).<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
Response.End
else
sizeFile=AF_valueLen
end if
case else
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(AF_curPath) & UploadRequest.Item(AF_curKey).Item("FileName") & "<br>"
Response.Write "File extensions should only be ""jpg.""<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
Response.End
end select
end if
next

Dim numFileName
numFileName = 1

for AF_i = 0 to UploadRequest.Count - 1
AF_curKey = AF_keys(AF_i)

if UploadRequest.Item(AF_curKey).Item("FileName") <> "" then
AF_value = UploadRequest.Item(AF_curKey).Item("Value")
AF_valueBeg = UploadRequest.Item(AF_curKey).Item("ValueBeg")
AF_valueLen = UploadRequest.Item(AF_curKey).Item("ValueLen")

Dim AF_strm1, AF_strm2
Set AF_strm1 = Server.CreateObject("ADODB.Stream")
Set AF_strm2 = Server.CreateObject("ADODB.Stream")

AF_strm1.Open
AF_strm1.Type = 1

AF_strm2.Open
AF_strm2.Type = 1

AF_strm1.Write RequestBin
AF_strm1.Position = AF_ValueBeg
AF_strm1.CopyTo AF_strm2,AF_ValueLen

AF_curPath = Request.ServerVariables("PATH_INFO")
AF_curPath = Trim(Mid(AF_curPath,1,InStrRev(AF_curPath,"/")) & "")

if Mid(AF_curPath,Len(AF_curPath),1) <> "/" then
AF_curPath = AF_curPath & "/"
end if

on error resume next

Dim imgFolderName, numFile
imgFolderName = "\image\"

numFile = Right("00000000"&session("id"),8)&Right(LCase(UploadRequest.Item(AF_curKey).Item("FileName")),4)

AF_strm2.SaveToFile Trim(Server.mappath(AF_curPath)) & imgFolderName & numFile,2
imgFileName(AF_i) = numFile

numFileName = numFileName + 1


if err then
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(AF_curPath) & UploadRequest.Item(AF_curKey).Item("FileName") & "<br>"
Response.Write "Maybe the destination directory does not exist, or you don't have write permission.<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
err.clear
Response.End
end if
end if
next

Dim sFileName(1), i
for AF_i = 0 to UploadRequest.Count - 1
If imgFileName(AF_i) <> "" Then
for i = 0 to 1
If sFileName(i) = "" Then
sFileName(i) = imgFileName(AF_i)
exit for
End If
next
End If
next%>

<%set Conn=Server.CreateObject("ADODB.Connection")
Conn.Provider="Microsoft.Jet.OLEDB.4.0"
Conn.Open Server.MapPath("../db/db.mdb")

Sql="SELECT * FROM member "
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open Sql,Conn,1,3

If sFileName(0)<>"" Then
rs.Addnew
rs("Picture")=sFileName(0)
rs.Update
end if


rs.Close : Set rs = Nothing
Conn.close : set conn=Nothing%>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 24 เม.ย. 2548 20:13:40 By : ssaii View : 2706 Reply : 2
 

 

No. 1

Guest


แล้วผมจะช่วยดูตรงไหนละครับ






Date : 25 เม.ย. 2548 14:20:27 By : Ton
 


 

No. 2

Guest


กรณีเกิด ERROR ถ้าแสดงคำที่มันฟ้อง ERROR ด้วยก้อดีอ่ะครับ เพื่อจะได้รู้ถึงปัญหาและแก้ได้ตรงจุดอ่าครับ
Date : 3 พ.ย. 2548 10:39:26 By : มือใหม่
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ดู code ให้หน่อยครับ ช่วยดูให้หน่อยครับว่าทำไมมันถึง upload รูปไม่ได้ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่