[ASP] Bestanden uploaden

Pagina: 1
Acties:
  • 100 views sinds 30-01-2008
  • Reageer

  • Moriaty
  • Registratie: December 1999
  • Laatst online: 11-08 14:06
Heeft iemand een idee hoe dit kan ZONDER additionele componenten die geinstalleerd moeten worden?

"640K ought to be enough for anybody." - Bill Gates, 1981


Verwijderd

wat bedoel je nou precies

  • Crazy D
  • Registratie: Augustus 2000
  • Laatst online: 10-09 14:16

Crazy D

I think we should take a look.

Ja dat kan... en als je ff zoekt op asp fileupload, er zijn al een aantal posts geweest waarin de code gegeven is.

Exact expert nodig?


  • j_du_pee
  • Registratie: Maart 2000
  • Laatst online: 23-09-2024

j_du_pee

du pain, du vin, du pee

kaart != map && bottel != fles
Wacht op antwoord


  • jelmervos
  • Registratie: Oktober 2000
  • Niet online

jelmervos

Simple user

Op vrijdag 29 maart 2002 11:18 schreef j_du_pee het volgende:
heb je hier wat aan:
http://www.4guysfromrolla.com/webtech/012401-1.shtml
Volgens mij gebruikt die juist extra componenten.

"The shell stopped unexpectedly and Explorer.exe was restarted."


  • Scare360
  • Registratie: Juli 2001
  • Laatst online: 21:54
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
'@ $Archive: /Common/Uploader.asp$
'@ Version: 0.02d   dd: 2001-02-10
'@ P.Gielens, p.gielens@connexx.nl
'@ Copyright Connexx Communications

'Build uploadBin
Function BuildUpload(RequestBin)

  PosBeg = 1
  PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
  boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
  boundaryPos = InstrB(1,RequestBin,boundary)
  
  'Get all data inside the boundaries
  Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
    'Members variable of objects are put in a dictionary object
    Dim UploadControl
    
    Set UploadControl = CreateObject("Scripting.Dictionary")
    
    'Get an object name
    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)
    
    'Test if object is of file type
    If PosFile<>0 AND (PosFile<PosBound) Then
    'Get Filename, content-type and content of file
    PosBeg = PosFile + 10
    PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
    FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
    
    'Add filename to dictionary object
    UploadControl.Add "FileName", FileName
    Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
    PosBeg = Pos+14
    PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
    
    'Add content-type to dictionary object
    ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
    UploadControl.Add "ContentType",ContentType
    
    'Get content of object
    PosBeg = PosEnd+4
    PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
    Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
    Else
    'Get content of object
    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 Function

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

If request("Action")="1" then
  Response.Clear
  byteCount = Request.TotalBytes
     
  RequestBin = Request.BinaryRead(byteCount)
     
  Set UploadRequest = CreateObject("Scripting.Dictionary")

  BuildUpload(RequestBin)
     
  If UploadRequest.Item("blob").Item("Value") <> "" Then

    contentType = UploadRequest.Item("blob").Item("ContentType")
    filepathname = UploadRequest.Item("blob").Item("FileName")
    filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
    FolderName = UploadRequest.Item("where").Item("Value")
    If DEBUG = true Then Response.Write "FolderName: " & FolderName & "<BR>" End If
    Path = Mid(Request.ServerVariables("PATH_TRANSLATED"), 1, Len(Request.ServerVariables("PATH_TRANSLATED")) - Len(Request.ServerVariables("PATH_INFO"))) & "\" 
    If DEBUG = true Then Response.Write "Path:" & Path & "<BR>" End If
    ToFolder = Path & "\" & FolderName
    value = UploadRequest.Item("blob").Item("Value")
    filename = ToFolder & "\" & filename
    Set MyFileObject = Server.CreateObject("Scripting.FileSystemObject")
    Set objFile = MyFileObject.CreateTextFile(filename)
    If DEBUG = true Then Response.Write "Saved Path: " & filename End If
    For i = 1 to LenB(value)
    objFile.Write chr(AscB(MidB(value,i,1)))
    Next        
    objFile.Close
    Set objFile = Nothing
    Set MyFileObject = Nothing
  End If

Svp header intact houden. Ik acht mezelf niet verantwoordelijk voor mogelijk exploids / bugs in deze code...gebruiken op eigen risico dus!

  • j_du_pee
  • Registratie: Maart 2000
  • Laatst online: 23-09-2024

j_du_pee

du pain, du vin, du pee

Op vrijdag 29 maart 2002 11:40 schreef jelmervos het volgende:

[..]

Volgens mij gebruikt die juist extra componenten.
oh.. Ik had de inleiding (van het artikel) gelezen, daar begreep ik uit dat hij juist een manier zocht om te uploaden zonder componenten registreren.

case else:
sowwy :)


[/code]

kaart != map && bottel != fles
Wacht op antwoord


  • raptorix
  • Registratie: Februari 2000
  • Laatst online: 17-02-2022
Zonder componenten uploaden is niet mogelijk >:)

  • Crazy D
  • Registratie: Augustus 2000
  • Laatst online: 10-09 14:16

Crazy D

I think we should take a look.

Op vrijdag 29 maart 2002 13:03 schreef raptorix het volgende:
Zonder componenten uploaden is niet mogelijk >:)
:D je Class en de Dictionary object even niet als component meerekenen :P dan kan 't wel :)

Exact expert nodig?


Verwijderd

Misschien heb je hier iets aan:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=6607&lngWId=4

is asp voor het webbased versturen van mail met attachemnt dat ik ooit eens geschreven heb. De file wordt eerst ge-upload naar de web/smtp server en dan verstuurd. Het deel dat de upload verzorgt zou bruikbaar voor je moeten zijn.
Pagina: 1