 |
|
ทำอย่างไร ให้จำกัด ขนาดรูปภาพไม่ให้เกิน 50 k แล้วมีข้อความขึ้นว่า ภาพของคุณมีขนาดเกิน50 k กรุณาเปลี่ยนภาพ |
|
 |
|
|
 |
 |
|
คือไม่อยากให้ภาพมันใหญ่เกิน 50 k แก้ให้ทีนะครับ ขอบคุณล่วงหน้า
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\pic"))
filename1 =Right(filename,4)
if filename="" then
' Response.Write "คุณยังไม่ได้เลือกรูปเลยครับ กรุณากลับไปเลือกรูปก่อน"
newfilename = "nopic.jpg"
else
mdate=replace(date(),"/","")
mtime=replace(time(),":","")
ntime=left(mtime,5)
newname=mdate+ntime
value = UploadRequest.Item("blob").Item("Value")
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(Server.mappath(newname&filename1))
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
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))
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 = MidB(RequestBin,PosBeg,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))
End If
UploadControl.Add "Value" , Value
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
newfilename=newname+filename1
end if
gip=Request.ServerVariables("REMOTE_ADDR")
gdate=now()
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "DRIVER={Microsoft Access Driver (*.MDB)};DBQ=" & Server.Mappath("db/job.mdb")
Set Session("job_conn") = conn
sql = "SELECT * FROM [question]"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3, 3
gtotal=rs.RecordCount
gtotal=gtotal+1
On Error Resume Next
rs.Addnew
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
16 Apr 2546 00:57:13 |
By :
ป๋อม |
View :
4701 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในบทเรียนมีอยูอะครับ
|
 |
 |
 |
 |
Date :
วันอาทิตย์ 20 เม.ย. 2546 เวลา 08:56:49 น. |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมติดตั้ง Window Server 2012 R2
เขียน code upload แล้ว เกิด error
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
ในบรรทัดนั้นมี Code : MyFile.Write chr(AscB(MidB(value,i,1)))
Run ในเครื่องอื่นไม่เป็นไรครับ พอมาในเครื่องนี้เป็น
คิดว่าน่าจะเป็นจาก IIS configuration
พอจะมีทางแก้ไขได้อย่างไรครับ
|
 |
 |
 |
 |
Date :
2020-11-11 16:18:26 |
By :
ชัชวาลย์ สุขสุทธิ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|