---
title: "max storlek på bild upload"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/100618-max-storlek-på-bild-upload"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "mackz"
published: "2004-03-30T09:34:09.000Z"
updated: "2004-03-31T09:08:43.000Z"
replies: 9
views: 304
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/100618-max-storlek-på-bild-upload"
---

# max storlek på bild upload

## #1 — mackz, 2004-03-30T09:34Z

Sitter och lurar på det här med att ladda upp bild och vill ha max storlek ..       Har kommit så här långt men det jag saknar är även ett fel medelande.

Vill ha max 80kb och tex.  filen är för stor.

```
Save the file to the database
		If File.FileSize < 80000 Then
			File.SaveToDatabase RecSet("picture")
		End if
```

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

## #2 — m_soderlund, 2004-03-30T09:42Z

Exempelvis [så här](http://www.webforum.nu/showthread.php?s=&postid=365737#post365737). :)

Eller varför inte:

```
File.SetMaxSize 80000
```

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

## #3 — mackz, 2004-03-30T09:50Z

Ja  :)    Men när det gäller att ge ett fel medelande pga för stor bild..  går det

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

## #4 — Palle, 2004-03-30T10:35Z

ex.. 

```
[red]If File.FileSize < 80000 Then
	File.SaveToDatabase RecSet("picture")
	strMessage = "Din bild är nu uppdaterat!"
Else
	strMessage = "Din bild är större än 80kb! Ajjabajja! Gör om - gör rätt!"
End If

Response.Write strMessage[/red]
```

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

## #5 — mackz, 2004-03-30T10:36Z

Detta funkar men det är i det som det skulle vara ett fel mess.  Nu fortsätter scriptet utan att ladda upp bilden bara.

```
RecSet("picture_type")=""

If Uploader.Files.Count > 0 Then
	
	' Loop through the uploaded files
	For Each File In Uploader.Files.Items
		
		If File.FileSize < 80000 Then
		
			' Save content-type to database
			RecSet("picture_type") = File.ContentType
						
			' Save the file to the database
			File.SaveToDatabase RecSet("picture")
		End If
		
	Next
End If
```

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

## #6 — Palle, 2004-03-30T10:41Z

```
[red]RecSet("picture_type") = ""

If Uploader.Files.Count > 0 Then
	
	' Loop through the uploaded files
	For Each File In Uploader.Files.Items
		
		If File.FileSize < 80000 Then
		
			' Save content-type to database
			RecSet("picture_type") = File.ContentType
						
			' Save the file to the database
			File.SaveToDatabase RecSet("picture")

		[blue]Else
			Response.Write "Filen är för stor! Ajjabajja!"
			Exit For[/blue]

		End If
		
	Next

End If[/red]
```

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

## #7 — mackz, 2004-03-30T10:49Z

får bara skriptet att köra igenom utan att lägga in en bild..    Här är hela save scriptet.

```
<%
' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ="& db

Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select * From annons"
Recset.Open Addera, Conn, 3, 3

RecSet.AddNew

RecSet("pris") = Uploader.Form("pris")
RecSet("kategori") = Uploader.Form("kategori")
RecSet("namn") = Uploader.Form("namn")
RecSet("rubrik") = Uploader.Form("rubrik")
RecSet("text") = Uploader.Form("text")
RecSet("epost") = Uploader.Form("epost")
RecSet("landskap") = Uploader.Form("landskap")

RecSet("date") = now()
RecSet("adtype") = Uploader.Form("adtype")
RecSet("pwd") = Uploader.Form("pwd")
RecSet("ip") = Request.ServerVariables("REMOTE_ADDR")

RecSet("picture_type") = ""

If Uploader.Files.Count > 0 Then
	
	' Loop through the uploaded files
	For Each File In Uploader.Files.Items
		
		If File.FileSize < 80000 Then
		
			' Save content-type to database
			RecSet("picture_type") = File.ContentType
						
			' Save the file to the database
			File.SaveToDatabase RecSet("picture")

		Else
			Response.Write "Filen är för stor! Max 80kb"
			Exit For

		End If
		
	Next

End If

RecSet.Update
RecSet.Close
Conn.Close

'Response.Redirect uploadImage.htm
Response.Redirect "../start.asp"
%>
```

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

## #8 — Palle, 2004-03-30T10:55Z

> Microsoft Access Driver

Finns det *blob*\-fält i MS Access som du kan spara bilder i?

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

## #9 — mackz, 2004-03-30T10:59Z

det sparas i picture i mdb

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

## #10 — mackz, 2004-03-31T09:08Z

Löste det så här.

```
RecSet("picture_type") = ""

If Uploader.Files.Count > 0 Then
	
	' Loop through the uploaded files
	For Each File In Uploader.Files.Items
		
		If File.FileSize < 60000 Then
		
			' Save content-type to database
			RecSet("picture_type") = File.ContentType
						
			' Save the file to the database
			File.SaveToDatabase RecSet("picture")

		Else
			Response.Write "Bilden är för stor! Max 60kb Tryck på bakåt knappen och försök igen."
			set fso = nothing
      response.end

		End If
		
	Next

End If
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/100618-max-storlek-på-bild-upload
