16. april 2004 - 08:24Der er
8 kommentarer og 1 løsning
ASP upload! Hjælp
Hvordan gemmer jeg de enkelte filer i 2 forskellige mapper?
Scriptet ser pt. således ud, men den skal også gemme den samme fil i denne mappe ../../uploads/
Set objUpload = Server.CreateObject("Persits.Upload.1")
With objUpload
'make sure files arn't over written .OverwriteFiles = False
'We need to save the file before we can find out anything about it '** Save virtual is used as saving to memory is often disabled by the web host ** .SaveVirtual strFileUploadPath
'Get the file name strNewFileName = .Files(1).ExtractFileName
'Remove brackets that aspUpload may put in when renaming a file strNewFileName = Replace(strNewFileName, "(", "", 1, -1, 1) strNewFileName = Replace(strNewFileName, ")", "", 1, -1, 1)
'Check the file size is not above the max allowed size, this is done using a function not the compoent to stop an exception error lngErrorFileSize = fileSize(.Files(1).Size, intMaxFileSize)
'Loop through all the allowed extensions and see if the file has one blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
'If the file is OK save it to disk If lngErrorFileSize = 0 AND blnExtensionOK = True Then
'** AspUpload does have a function to stop files form being over written but this can allow the forum open to malicious code ** '** so instead if the file exists create an acceptable new name for the file ** 'Check to make sure the file does not already exist Do While .FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
'Create a new file name for the file if it already exsist strNewFileName = hexValue(3) & "_" & strNewFileName Loop
'Save the file to disk with new file name '** Copy virtual is used as save as is often disabled by the web host ** .Files(1).CopyVirtual strFileUploadPath & "/" & strNewFileName
'As a new copy of the file is saved we need to get rid of the old copy .Files(1).Delete
'Pass the filename back fileUpload = strNewFileName
'Else if it is not OK delete the uploaded file Else .Files(1).Delete
arh... Ok... Jeg havde ikke helt forstået dit spg på den måde..
Prøv det her..
Set objUpload = Server.CreateObject("Persits.Upload.1")
With objUpload
'make sure files arn't over written .OverwriteFiles = False
'We need to save the file before we can find out anything about it '** Save virtual is used as saving to memory is often disabled by the web host ** .SaveVirtual strFileUploadPath
'Get the file name strNewFileName = .Files(1).ExtractFileName
'Remove brackets that aspUpload may put in when renaming a file strNewFileName = Replace(strNewFileName, "(", "", 1, -1, 1) strNewFileName = Replace(strNewFileName, ")", "", 1, -1, 1)
'Check the file size is not above the max allowed size, this is done using a function not the compoent to stop an exception error lngErrorFileSize = fileSize(.Files(1).Size, intMaxFileSize)
'Loop through all the allowed extensions and see if the file has one blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
'If the file is OK save it to disk If lngErrorFileSize = 0 AND blnExtensionOK = True Then
'** AspUpload does have a function to stop files form being over written but this can allow the forum open to malicious code ** '** so instead if the file exists create an acceptable new name for the file ** 'Check to make sure the file does not already exist Do While .FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
'Create a new file name for the file if it already exsist strNewFileName = hexValue(3) & "_" & strNewFileName Loop
'Save the file to disk with new file name '** Copy virtual is used as save as is often disabled by the web host ** .Files(1).CopyVirtual strFileUploadPath & "/" & strNewFileName .Files(1).CopyVirtual "../../uploads/" & strNewFileName
'As a new copy of the file is saved we need to get rid of the old copy .Files(1).Delete
'Pass the filename back fileUpload = strNewFileName
'Else if it is not OK delete the uploaded file Else .Files(1).Delete
Klik på knappen Opdater, eller forsøg igen senere.
Åbn localhost hjemmesiden, og søg derefter efter hyperlinks til de ønskede oplysninger. HTTP 500,100 - Intern fejl på serveren - ASP-fejl - Internet Information Services
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.