---
title: "Hämta bild från webb"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/96688-hämta-bild-från-webb"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Glitter"
published: "2004-02-06T08:37:52.000Z"
updated: "2004-02-06T12:51:13.000Z"
replies: 3
views: 226
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/96688-hämta-bild-från-webb"
---

# Hämta bild från webb

## #1 — Glitter, 2004-02-06T08:37Z

jag har ett litet problem med att spara ned bilder från en websida 
jag får ned information om bilden och jag kan spara ned den men informationen är inte samma som orginalet och jag kan inte titta på den nedsparade bilden hur skall jag göra ??

```
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")

objHTTP.Open "GET", url & "bild.jpg" , False
objHTTP.setRequestHeader "Content-type","image/jpeg"
objHTTP.Send

text = objHTTP.responseBody

Set fs = CreateObject("Scripting.FileSystemObject")

fil = Server.MapPath("test.jpg")

if fs.FileExists(fil) then
	fs.DeleteFile(fil)
'end if

Set fss = fs.CreateTextFile(fil, true)
set fss = nothing

set fss = fs.OpenTextFile(fil, 2, true, TristateMixed)
fss.Writeline(text)
fss.Close

set fss = nothing
set fs = nothing
```

Permalänk: https://www.webforum.nu/p/96688

## #2 — Glitter, 2004-02-06T10:31Z

det löste sig :)

Permalänk: https://www.webforum.nu/p/1270027

## #3 — OveRRidE, 2004-02-06T11:11Z

Hur då? :q

Permalänk: https://www.webforum.nu/p/1270041

## #4 — Glitter, 2004-02-06T12:51Z

Så här:

```
Set bild_objHTTP = Server.CreateObject("Microsoft.XMLHTTP")

bild_objHTTP.Open "GET", bild_url , False
bild_objHTTP.setRequestHeader "Content-type","image/jpeg"
bild_objHTTP.Send

bildtext = bild_objHTTP.responseBody
bildtext = [B]BinToText(bild_objHTTP.responseBody,35000)[/B]

Set bild_fs = CreateObject("Scripting.FileSystemObject")

fil = filsokvag

if bild_fs.FileExists(fil) then
	bild_fs.DeleteFile(fil)
end if

Set bild_TextFile = bild_fs.CreateTextFile(fil)

bild_TextFile.Write(bildtext)
bild_TextFile.Close

set bild_fs = nothing
```

var tvungen att ha functionen för att konvertera:

```
function BinToText(varBinData, intDataSizeInBytes)
	const adFldLong = 128
	const adVarChar = 200
	set aobjRS = Server.CreateObject("ADODB.Recordset")
  
	aobjRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
	aobjRS.Open
	
	aobjRS.AddNew
	aobjRS.Fields("txt").AppendChunk(varBinData)
	tmp = aobjRS("txt").Value
	aobjRS.Close
	set aobjRS = nothing
	BinToText = tmp
	
	set objRS = nothing
end function
```

Permalänk: https://www.webforum.nu/p/1270119

---

Tråden på webben: https://www.webforum.nu/amne/asp/96688-hämta-bild-från-webb
