Avatar billede t_kris Nybegynder
06. oktober 2002 - 16:33 Der er 3 kommentarer og
1 løsning

Dundas.Upload.2

Er det muligt at få navnet på den file man uploade

koden ser således ud

<%
'most control methods throw an exception if an error occurs so we will use an
' On Error Resume Next statement for error trapping purposes
On Error Resume Next

'create an instance of the Upload control
Set objUpload = Server.CreateObject ("Dundas.Upload.2")

'we will save all uploaded data (form data as well as any uploaded files) to disk.
'note that we could also save the uploaded files to memory with the SaveToMemory method.
'also note that both the Save and SaveToMemory methods populate the Form and
' Files collections with one method call.
'its also important to realize that by default files saved to disk will have unique filenames, but
' this can be changed with the UseUniqueNames property
objUpload.Save "D:\websider\resadmin\ecomp.dk\ecomp.dk\www\hatest\pic\"

'check to see if method call was successful using VBScript's Err object, if
' an error occurred we will redirect user to a fictitious error page
If Err.Number <> 0 Then
Response.Redirect "Error.asp"
Else
'use a For Each loop and check to see if the uploaded file is an
' executable (utilizing VBScript's InStr method), if it is delete it from disk.
'but first we will output the name of the file input box(es) responsible for uploads
For Each objUploadedFile in objUpload.Files
Response.Write "The &quot;" & objUploadedFile.TagName & "&quot; file input box was used to upload a file.<br>"
If InStr(1,objUploadedFile.ContentType,"octet-stream") Then
'if the default web account does not have the right to delete files
' for the folder you save uploaded files to (in this case c:\temp) then you can either set
' the required rights manually or you could use the ImpersonateUser method
objUploadedFile.Delete
End If
Next

'we will just output the name of the populated form elements and their values
For Each objFormItem In objUpload.Form
Response.Write "<br>The name of the form item is: " & objFormItem
Response.Write "<br>The value of the form item is: " & objFormItem.Value & "<br>"
Next

End If

'Release resources
Set objUpload = Nothing
Avatar billede medions Nybegynder
06. oktober 2002 - 17:08 #1
objUploadedFile.ExtractFileName

//>Rune
Avatar billede t_kris Nybegynder
06. oktober 2002 - 17:59 #2
Jeg synes ikke det virker
Avatar billede medions Nybegynder
06. oktober 2002 - 19:10 #3
Så prøv med

objUpload.ExtractFileName
eller
objUpload.FileName

//>Rune
Avatar billede t_kris Nybegynder
18. januar 2003 - 11:09 #4
lukket
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester