19. januar 2008 - 20:07Der er
2 kommentarer og 1 løsning
FreeAspUload filnavn
Hej Eksperter
Jeg bruger FreeAspUload til at uploade nogle billeder til serveren. Jeg har dog problemer med at finde ud af, hvordan man finder filnavnet på filen, man har upload'et. Jeg har indsat upload-scriptet herunder. Håber der er nogen, der kan hjælpe :-)
Dim Upload, fileName, fileSize, ks, i, fileKey Dim uploadsDirVar Dim img_filename uploadsDirVar = server.mappath(".") & "\content_images" Set Upload = New FreeASPUpload Upload.Save(uploadsDirVar)
Set fs2 = CreateObject("Scripting.FileSystemObject") antal = fs2.GetFolder(pPath).Files.Count Set fs2 = Nothing
function SaveFiles
'Set Upload = New FreeASPUpload Upload.Save(uploadsDirVar) ' If something fails inside the script, but the exception is handled If Err.Number<>0 then Exit function SaveFiles = "" ks = Upload.UploadedFiles.keys if (UBound(ks) <> -1) then SaveFiles = "<B>Filer sendt til server:</B> " for each fileKey in Upload.UploadedFiles.keys img_filename = Upload.UploadedFiles(fileKey) SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " next else SaveFiles = "<strong>Ugyldigt filnavn!</strong>" end if
Jeg kan dog ikke helt få det til at virke. Hvad går der galt her:
function SaveFiles
'Set Upload = New FreeASPUpload Upload.Save(uploadsDirVar) ' If something fails inside the script, but the exception is handled If Err.Number<>0 then Exit function SaveFiles = "" ks = Upload.UploadedFiles.keys if (UBound(ks) <> -1) then SaveFiles = "<B>Filer sendt til server:</B> "
my_filename = Upload.FileName
for each fileKey in Upload.UploadedFiles.keys Response.Write(my_filename) SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " next else SaveFiles = "<strong>Ugyldigt filnavn!</strong>" end if
Fik endelig løst det. Ikke helt, Upload.FileName, men nu er den der:
Dim Upload, fileName, fileSize, ks, i, fileKey, uploadsDirVar, img_filename uploadsDirVar = server.mappath(".") & "\content_images"
Set Upload = New FreeASPUpload Upload.Save(uploadsDirVar)
for each fileKey in Upload.UploadedFiles.keys img_filename = Upload.UploadedFiles(fileKey).FileName SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " next
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.