---
title: "Problem vid uppladdning"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/108851-problem-vid-uppladdning"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Mika3l"
published: "2004-08-09T18:56:35.000Z"
updated: "2004-08-09T19:15:28.000Z"
replies: 4
views: 217
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/108851-problem-vid-uppladdning"
---

# Problem vid uppladdning

## #1 — Mika3l, 2004-08-09T18:56Z

Håller på att pilla med ett administrationssystem där man ska kunna ladda upp filer (fem åt gången, file1, file2 osv). Slumpade siffror och bokstäver och ett \_ ska läggas till före namnet.
Det fungerade först då jag lade function getRndNr före For each file In objUpload.Files men nu får jag följande felmeddelande:

> Kompileringsfel i Microsoft VBScript (0x800A03EA)
> Syntaxfel
> /ufm/kp/files.asp, line 43
> Function getRndNr(lowbound,uppbound)

Koden (rad 43 är blå):

```
Dim objUpload, intCountFiles

Set objUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
objUpload.Upload

For each file In objUpload.Files

If not file.IsMissing Then

[blue]Function getRndNr(lowbound,uppbound)[/blue]
Randomize()
getRndNr = int( ( ( lowbound ) - ( uppbound + 1 ) ) * RND + ( uppbound + 1 ) )
End Function

Dim strRND

For i = 1 to 5
  strRND = strRND & chr( getRndNr( 97, 122 ) )
Next

For i = 1 to 5
  strRND = strRND & getRndNr( 1, 9 )
Next

file.SaveAs("/files/" & strRND & file.FileName)

'         Response.Write("Name = " & file.Name & "<BR>")
 '        Response.Write("Size = " & file.Size & "<BR>")
  '       Response.Write("FileName = " & file.FileName & "<BR>")
   '      Response.Write("FileExt = " & file.FileExt & "<BR>")
    '     Response.Write("FilePathName = " & file.FilePathName & "<BR>")
     '    Response.Write("ContentType = " & file.ContentType & "<BR>")
      '   Response.Write("ContentDisp = " & file.ContentDisp & "<BR>")
       '  Response.Write("TypeMIME = " & file.TypeMIME & "<BR>")
        ' Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>")
         'intCount = intCount + 1
      End If

intCountFiles = intCountFiles+1

Next

Response.Write(intCountFiles & " fil(er) har laddats upp.")
```

Tacksam för svar!

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

## #2 — solbulle, 2004-08-09T19:04Z

Flytta ut hela funktionen och lägg den innan all den andra koden.
Den skall defenitivt inte ligga där den ligger nu.

/red. Varför flyttade du på den om det fungerade?

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

## #3 — @nders, 2004-08-09T19:05Z

Du får inte ha en funktionsdefinition i en loop.

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

## #4 — Mika3l, 2004-08-09T19:11Z

Flyttade på den för att den skulle köras på nytt (enligt min tanke som kan ha varit felaktig) då bokstäverna och siffrorna blev lika.
Får flytta tillbaka den! :)

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

## #5 — Mika3l, 2004-08-09T19:15Z

Nu fungerar det helt perfekt! La till strRND = "" sist så att det blev en "nollställning".

Tack för hjälpen! :bire

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/108851-problem-vid-uppladdning
