Nån som vet hur kan konverterar detta till aspSmartUpload och enbart tillåta gif,jpg,png och mp3
<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = False
Upload.SetMaxSize 100000, False
Count=Upload.Save(Server.MapPath("/images/gallery"))
For Each file In Upload.Files
If File.ImageType = "UNKNOWN" Then
Response.Redirect "/pictureupload/gallery/?error=filetype"
File.Delete
End If
Next
For Each file In Upload.Files
If file.Size = 100000 Then
Response.Redirect "/pictureupload/gallery/?error=fileTooBig"
File.Delete
End If
Next
Set File = Upload.Files
rubrik = replace(Upload.form("txtRubrik"),"'","''")
kommentar = replace(Upload.form("txtKommentar"),"'","''")
If NOT File Is Nothing Then
On Error Resume Next
strFileName= Upload.Files("blob").ExtractFileName
END IF
Dim objConn
varTillhor=Session("userID")
upplagd = Now()
storlek=file.size
SET objConn = connect()
picture = "INSERT INTO tblUsers_Galleri"
picture = picture & "(bild,agare,inlagd,rubrik,kommentar) "
picture = picture & "VALUES('" & strFileName & "','"& varTillhor &"','"& upplagd&"','"& rubrik &"','"& kommentar &"')"
objConn.Execute picture
objConn.Execute("Update tblUsers SET poang = poang+0.8 WHERE userID= " & UserID &"")
%>
<%response.redirect "/pictureupload/gallery/?filename=" & strFileName & "&pic=" & strFileName & "&message=pic"%>
<form action="/test.asp?do=upload" method="post">
<input type="file" name="file">
<input type="submit">
</form>
<%if request("do") = "upload" then
On Error Resume Next
' Variables
' *********
Dim mySmartUpload
Dim intCount
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Only allow txt or htm files
' ***************************
mySmartUpload.AllowedFilesList = "htm,txt"
' DeniedFilesList can also be used :
' Allow all files except exe, bat and asp
' ***************************************
' mySmartUpload.DeniedFilesList = "exe,bat,asp"
' Deny physical path
' *******************
mySmartUpload.DenyPhysicalPath = True
' Only allow files smaller than 50000 bytes
' *****************************************
mySmartUpload.MaxFileSize = 50000
' Deny upload if the total fila size is greater than 200000 bytes
' ***************************************************************
mySmartUpload.TotalMaxFileSize = 200000
' Upload
' ******
mySmartUpload.Upload
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save("/Upload")
' sample with a physical path
' intCount = mySmartUpload.Save("c:\temp\")
' Trap errors
' ***********
If Err Then
Response.Write("<b>Wrong selection : </b>" & Err.description)
Else
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
End If
end if%>
<form action="/test.asp?do=upload" method="post">
<input type="file" name="file">
<input type="submit">
</form>
<%if request("do") = "upload" then
On Error Resume Next
' Variables
' *********
Dim mySmartUpload
Dim intCount
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Only allow txt or htm files
' ***************************
mySmartUpload.AllowedFilesList = "htm,txt"
' DeniedFilesList can also be used :
' Allow all files except exe, bat and asp
' ***************************************
' mySmartUpload.DeniedFilesList = "exe,bat,asp"
' Deny physical path
' *******************
mySmartUpload.DenyPhysicalPath = True
' Only allow files smaller than 50000 bytes
' *****************************************
mySmartUpload.MaxFileSize = 50000
' Deny upload if the total fila size is greater than 200000 bytes
' ***************************************************************
mySmartUpload.TotalMaxFileSize = 200000
' Upload
' ******
mySmartUpload.Upload
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save("/Upload")
' sample with a physical path
' intCount = mySmartUpload.Save("c:\temp\")
' Trap errors
' ***********
If Err Then
Response.Write("<b>Wrong selection : </b>" & Err.description)
Else
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
End If
end if%>
<form action="/test.asp?do=upload&test=yes" method="post" ENCTYPE="multipart/form-data" >
<input type="file" name="file">
<input type="submit">
</form>
<%if request("do") = "upload" then
On Error Resume Next
' Variables
' *********
Dim mySmartUpload
Dim intCount
' Object creation
' ***************
Request.QueryString("test")
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.Files("file")
' Only allow txt or htm files
' ***************************
mySmartUpload.AllowedFilesList = "htm,txt"
' DeniedFilesList can also be used :
' Allow all files except exe, bat and asp
' ***************************************
' mySmartUpload.DeniedFilesList = "exe,bat,asp"
' Deny physical path
' *******************
mySmartUpload.DenyPhysicalPath = True
' Only allow files smaller than 50000 bytes
' *****************************************
mySmartUpload.MaxFileSize = 50000
' Deny upload if the total fila size is greater than 200000 bytes
' ***************************************************************
mySmartUpload.TotalMaxFileSize = 200000
' Upload
' ******
mySmartUpload.Upload
mySmartUpload.Files("test")
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save("/Upload")
' sample with a physical path
' intCount = mySmartUpload.Save("c:\temp\")
' Trap errors
' ***********
If Err Then
Response.Write("<b>Wrong selection : </b>" & Err.description)
Else
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
End If
end if%>
1. Det finns två komponenter med nästan samma namn. ASP Smart Upload och ASP Upload tror jag dom heter, och är inte samma sak.
2. Enklaste sättet att ta bort en fil är med FSO: (Fungerar oberoende av komponent)
myVar = request("delete")
IF myVar <> "" THEN
SQL = "SELECT intID, strFileName FROM [" & myTable & "] WHERE intID = " & myVar & ""
set mySQL = Conn.Execute(SQL)
' ## DELETE FILE
Set fso = Server.CreateObject("Scripting.FileSystemObject")
IF fso.fileExists( server.MapPath("\images\" & mySQL(1) ) ) THEN
fso.DeleteFile(Server.MapPath("\images\") & "\" & mySQL(1))
END IF
IF fso.fileExists( server.MapPath("\images\low_" & mySQL(1) ) ) THEN
fso.DeleteFile(Server.MapPath("\images\") & "\low_" & mySQL(1))
END IF
IF fso.fileExists( server.MapPath("\images\mid_" & mySQL(1) ) ) THEN
fso.DeleteFile(Server.MapPath("\images\") & "\mid_" & mySQL(1))
END IF
IF fso.fileExists( server.MapPath("\images\high_" & mySQL(1) ) ) THEN
fso.DeleteFile(Server.MapPath("\images\") & "\high_" & mySQL(1))
END IF
Set fso = Nothing
END IF
Jag vet att en av de andra komponenterna komprimerade bilder på ett mycket dåligt sätt. Minns ej om det var ASPUpload eller ASPSmarUpload!! Men ska ta reda på det...
*kollar*
Nej, jag kör ASPSmarUpload och då är det ASPUpload du helst inte ska använda. Jag har kört ASPJpeg till vissa kunder...
Får jag bara till koden för aspSmartUpload så använder jag den, och vill hellre ha denna komponent eftersom jag vill kunna skicka upp mp3, wav och zip-filer förutom bildformaten istället för aspJpeg