---
title: "Störren en vis storlek förbjud"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/158829-störren-en-vis-storlek-förbjud"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "SGuncel"
published: "2007-04-01T05:13:07.000Z"
updated: "2007-04-06T09:28:37.000Z"
replies: 17
views: 795
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/158829-störren-en-vis-storlek-förbjud"
---

# Störren en vis storlek förbjud

## #1 — SGuncel, 2007-04-01T05:13Z

Hej!

Jag undrar vilken komponent man ska änvända om man vill förbjuda ladda upp en bild om den är störren vis storlek.

Jag tänkte att man skulle ladda upp en bild och det ska vara .GIF format, 60x11 och inte större än 60x11. Om den är störren ska det förbjudas.

Vilken komponent ska jag använda för det och skulle någon hjälpa hur jag ska göra det?

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

## #2 — headbug, 2007-04-01T07:38Z

Vad använder du för komponent för att ladda upp bilder till att börja med? Jag tror att de kommersiella som finns redan har inbyggt stöd för det, jag använder det på Loopia tex och dom kör ASPUpload och ASPJpeg, som funkar bra!

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

## #3 — SGuncel, 2007-04-01T09:20Z

Jag kör Dundas Upload och ASPJpeg.
Har Neno som webbhotell

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

## #4 — headbug, 2007-04-01T09:28Z

Ok, med ASPJpeg så har du ju tillgång till både width och height. Om ditt jpeg-objekt heter MyJpeg kan du kolla MyJpeg.Width och MyJpeg.Height. Det står ganska tydligt i ASPJpegs utmärkta online-manual. Vill du begränsa får du alltså i koden någonstans göra en if-sats som jämför. Du kan också automatiskt skala om bilder som är i fel storlek, om du vill det.

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

## #5 — SGuncel, 2007-04-01T09:42Z

Jo, jag vet det men problemet är att jag har aldrig använr ASPJpeg. Det är första gången jag ska göra det. Och vet inte hur de ska vara. Skulle du kunna visa vilken manual det är du menar?

Det ät så att man ska kunna ladda upp ikoner till sin klubb som man har skapat på min sida.

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

## #6 — headbug, 2007-04-01T09:58Z

Aha!

Manualen finns på <http://www.aspjpeg.com/manual.html>

Dessvärre måste man nog se hur din kod är uppbyggd för att kunna implementera en storlekskontroll på rätt sätt.

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

## #7 — SGuncel, 2007-04-01T10:34Z

Har ännu inte börjat koda för att ladda upp ikonen. Ska börja nu och behövde hjälp med det :)

Har kollat igenom men vet inte vilken av manualen jag ska läsa. Alla resizar bilderna.

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

## #8 — SGuncel, 2007-04-02T20:24Z

Någon som vet hur jag ska lösa detta?

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

## #9 — emission, 2007-04-02T21:11Z

På sidan <http://www.aspjpeg.com/manual_03.html> finns ett par exempel där man plockar ut filens storlek (OriginalWidth etc.)

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

## #10 — SGuncel, 2007-04-02T21:42Z

Jahap, men man behöver ASPUpload och jag använder inte det.

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

## #11 — colione, 2007-04-02T22:19Z

Det behöver du väl inte alls, du behöver bara ha sökvägen till filen, enda skälet till att de väljer art använda aspupload som komponent är ju för att det är samma tillverkare.

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

## #12 — SGuncel, 2007-04-02T22:42Z

> **emission skrev:**
>
> På sidan <http://www.aspjpeg.com/manual_03.html> finns ett par exempel där man plockar ut filens storlek (OriginalWidth etc.)

> **colione skrev:**
>
> Det behöver du väl inte alls, du behöver bara ha sökvägen till filen, enda skälet till att de väljer art använda aspupload som komponent är ju för att det är samma tillverkare.

Okej, men vilken av koderna ska jag ha? :S

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

## #13 — colione, 2007-04-03T06:11Z

Den här:

```
 <%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Compute path to save uploaded files to
Path = Server.MapPath(".")

' Capture uploaded file. Return the number of files uploaded
Count = Upload.Save(Path)

If Count = 0 Then
  Response.Write "No images selected."
  Response.End
Else
  ' Obtain File object representing uploaded file
  Set File = Upload.Files(1)

  ' Is this a valid image file?
  If File.ImageType <> "UNKNOWN" Then

    ' Create instance of AspJpeg object
    Set jpeg = Server.CreateObject("Persits.Jpeg")

    ' Open uploaded file
    jpeg.Open( File.Path )

    ' Resize image according to "scale" option.
    ' We cannot use Request.Form, so we use Upload.Form instead.
    jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
    jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

    SavePath = Path & "\small_" & File.ExtractFileName

    ' AspJpeg always generates thumbnails in JPEG format.
    ' If the original file was not a JPEG, append .JPG ext.
    If UCase(Right(SavePath, 3)) <> "JPG" Then
      SavePath = SavePath & ".jpg"
    End If

    jpeg.Save SavePath

    ' Save both images in the database along with description.
    strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb")

    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open "images", strConnect, 1, 3
    rs.AddNew

    ' Use File.Binary to access binary data of uploaded file.
    rs("original_image").Value = File.Binary
    Set ThumbFile = Upload.OpenFile(SavePath)
    rs("thumbnail").Value = ThumbFile.Binary
    rs("description") = Upload.Form("Description")
    rs.Update
    rs.Close
    Set rs = Nothing

    Response.Write "Success!"
  Else
    Response.Write "This is not a valid image."
    Response.End
  End If
End If
%>
```

Dock så får du modifiera uppladdningskomponenten så den passar dig.

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

## #14 — SGuncel, 2007-04-03T09:11Z

Har kommit ända hit med fick denna felet:
Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/upload.asp, line 18 

Path = Upload.save server.mappath("Bilder\\")
\-------------------^

```
<!-- #include file="_Inc/Conn.asp" -->
<body bgcolor="#FF99FF">

<form name="frmUpload" method="post" enctype="multipart/form-data" action="?Upload=groupIcon">
<div>
<input type="file" name="groupIcon" style="border-style:solid; border-width:1px; width: 480; font-family:Trebuchet MS; font-size:11px">
</div>
<div>
<input type="submit" value="Ladda upp" style="border-style:solid; border-width:1px; width: 99; font-family:Trebuchet MS; font-size:11px" name="LaddaUpp">
</div>
</form><%
IF Request.Querystring("Upload")="groupIcon" then

' Create an instance of AspUpload object
Set Upload = server.CreateObject("Dundas.Upload.2") 

' Compute path to save uploaded files to
Path = Upload.save server.mappath("Icons\")

' Capture uploaded file. Return the number of files uploaded
Count = Upload.Files(1)

If Count = 0 Then
  Response.Write "No images selected."
  Response.End
Else
  ' Obtain File object representing uploaded file
  Set Filename = Upload.Form("groupIcon")

  ' Is this a valid image file?
  If Filename.ImageType <> "UNKNOWN" Then

    ' Create instance of AspJpeg object
    Set jpeg = Server.CreateObject("Persits.Jpeg")

	Response.Write File.Path
	Response.End 

    ' Open uploaded file
    jpeg.Open( File.Path )

    ' Resize image according to "scale" option.
    ' We cannot use Request.Form, so we use Upload.Form instead.
    jpeg.Width = jpeg.OriginalWidth * Upload.Form("groupIcon") / 60
    jpeg.Height = jpeg.OriginalHeight * Upload.Form("groupIcon") / 10

    SavePath = Path & "\small_" & File.ExtractFileName

    ' AspJpeg always generates thumbnails in JPEG format.
    ' If the original file was not a JPEG, append .JPG ext.
    If UCase(Right(SavePath, 3)) <> "JPG" Then
      SavePath = SavePath & ".jpg"
    End If

    jpeg.Save SavePath

    ' Use File.Binary to access binary data of uploaded file.
    ObjConn.Execute("Update TLUsers set UsrPic='" &SavePath& "' where UsrID ="&SafeSQL(Session("UsrID"))&"")
	ObjConn.Close : Set ObjConn = Nothing 

    Response.Write "Success!"
  Else
    Response.Write "This is not a valid image."
    Response.End
  End If
End If
End If
%>
```

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

## #15 — colione, 2007-04-03T13:50Z

Provat med:
pixPath = server.mappath("Bilder\\")
Path = Upload.save(pixPath)

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

## #16 — voigtann1, 2007-04-03T14:11Z

eller

```
Path = Upload.save(server.mappath("Bilder\"))
```

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

## #17 — SGuncel, 2007-04-03T20:30Z

Nu får jag detta felet:
DSUpload.CollFiles.2 error '80070057' 

Index is out of range. 

/upload.asp, line 21 

De hära är rad 21
' Capture uploaded file. Return the number of files uploaded
Count = Upload.Files(1)

```
<!-- #include file="_Inc/Conn.asp" -->
<body bgcolor="#FF99FF">

<form name="frmUpload" method="post" enctype="multipart/form-data" action="?Upload=groupIcon">
<div>
<input type="file" name="groupIcon" style="border-style:solid; border-width:1px; width: 480; font-family:Trebuchet MS; font-size:11px">
</div>
<div>
<input type="submit" value="Ladda upp" style="border-style:solid; border-width:1px; width: 99; font-family:Trebuchet MS; font-size:11px" name="LaddaUpp">
</div>
</form><%
IF Request.Querystring("Upload")="groupIcon" then

' Create an instance of AspUpload object
Set Upload = server.CreateObject("Dundas.Upload.2") 

' Compute path to save uploaded files to
Path = Upload.save(server.mappath("Icons\"))

' Capture uploaded file. Return the number of files uploaded
Count = Upload.Files(1)

If Count = 0 Then
  Response.Write "No images selected."
  Response.End
Else
  ' Obtain File object representing uploaded file
  Set Filename = Upload.Form("groupIcon")

  ' Is this a valid image file?
  If Filename.ImageType <> "UNKNOWN" Then

    ' Create instance of AspJpeg object
    Set jpeg = Server.CreateObject("Persits.Jpeg")

	Response.Write File.Path
	Response.End 

    ' Open uploaded file
    jpeg.Open( File.Path )

    ' Resize image according to "scale" option.
    ' We cannot use Request.Form, so we use Upload.Form instead.
    jpeg.Width = jpeg.OriginalWidth * Upload.Form("groupIcon") / 60
    jpeg.Height = jpeg.OriginalHeight * Upload.Form("groupIcon") / 10

    SavePath = Path & "\small_" & File.ExtractFileName

    ' AspJpeg always generates thumbnails in JPEG format.
    ' If the original file was not a JPEG, append .JPG ext.
    If UCase(Right(SavePath, 3)) <> "JPG" Then
      SavePath = SavePath & ".jpg"
    End If

    jpeg.Save SavePath

    ' Use File.Binary to access binary data of uploaded file.
    ObjConn.Execute("Update TLUsers set UsrPic='" &SavePath& "' where UsrID ="&SafeSQL(Session("UsrID"))&"")
	ObjConn.Close : Set ObjConn = Nothing 

    Response.Write "Success!"
  Else
    Response.Write "This is not a valid image."
    Response.End
  End If
End If
End If
%>
```

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

## #18 — SGuncel, 2007-04-06T09:28Z

Nää, nu blir jag ledsen när ni bara lämnar så här :p

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/158829-störren-en-vis-storlek-förbjud
