[ASP] dwing jpg bestanden te downloaden

Pagina: 1
Acties:

  • GoVegan
  • Registratie: Juni 2002
  • Laatst online: 16-08 22:25
he hoi,

Momenteel probeer ik het met dit scriptje om een jpg bestand te downloaden, maar het enigste wat hij doet is een soort van jpg bestand aanmaken met de naam waarom je vraagt. hij pakt dus niet het echte bestand wat ik nodig heb. wel grappig maar heb er niet veel aan.
wat moet ik nog toevoegen aan de code om het wel voor elkaar te krijgen. zal vast wel een klein simpel iets zijn. maarja doe nog maar 2 weekje asp dus heb nog geen idee.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if(Request("wat") <> "") then wat__varwat = Request("wat")
%>


<%

FileName = wat__varwat
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename =" & filename
Set Stream = Server.CreateObject("ADODB.Stream")
Stream.Open
Stream.LoadFromFile Server.MapPath("/visuals/afbeelindingen\(Filename)")
Conents = Stream.ReadText
Response.BinaryWrite Contents
Stream.Close
Set Stream = Nothing
%>

  • pistole
  • Registratie: Juli 2000
  • Laatst online: 13:40

pistole

Frutter

misschien een typo: Conents i.p.v. Contents?

Verder heb ik niet inhoudelijk naar je script gekeken

Ik frut, dus ik epibreer


  • Kermit.de.Kikker
  • Registratie: Februari 2002
  • Laatst online: 26-08 22:20
Stream.LoadFromFile Server.MapPath("/visuals/afbeelindingen/" & Filename)

Verwijderd

Kijk hier maar 'ns naar:


ASP:
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
  '====================================================================
  ' Binary reads a document (Word, Excel, PDF, etc.) from the DIR_DOC_UPLOAD
  ' directory with the ADO stream object and returns to user.
  ' 
  ' querystring input: filename
  '====================================================================
  
    Dim strFilepath, strFilename, strFullpath, lngFileLenght
    
    strFilepath = Server.MapPath(Application("SiteBase") & DIR_DOC_UPLOAD)
    strFilename = Replace(Request("filename"),"../","") 'make sure downloads are only from DIR_DOC_UPLOAD
    strFullpath = strFilepath & "\" & strFilename
    
    Dim objStream
    Set objStream = Server.CreateObject("ADODB.Stream")

    objStream.Open
  objStream.Type = 1 'adTypeBinary
    
    objStream.LoadFromFile(strFullpath)
    lngFileLenght = objStream.Size

    '--- Set the appropriate ContentType here. Some examples are:
    '--- "application/x-msdownload" (automatic SaveAs box for both browsers)
    '--- "application/octet-stream" (binary data, may not be recognized by IE)
    '--- "image/jpeg"
    '--- "image/gif"
    '--- "text/plain", etc.

    'add response headers
    Response.Addheader "Content-Disposition", "attachment; filename=" & strFilename
    Response.AddHeader "Content-Length", lngFileLenght
    Response.ContentType = "application/octet-stream"
    Response.CacheControl = "public"
        
    'response (binary) to user  
    Response.BinaryWrite objStream.Read
    
    'clean up
    Set objStream = Nothing


:7