23. juli 2003 - 10:23Der er
30 kommentarer og 1 løsning
aspSmartUpload med email ?
Hej eksperter.
Jeg har et script hvor mine brugere kan uploade filer til en bestemt mappe på min server, hvor de efter at have klikket på send, for en ny side detaljeret med oplysninger om filerne.
Mit spørgsmål er nu, kan jeg indsætte en email, så jeg automatisk for samme besked som brugerne, bare på email ?
Og kan jeg sætte begrænsning på således at de kun kan upload f.eks. jpr, gif, bmp ect...
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
<% ' Variables ' ********* Dim mySmartUpload Dim file Dim intCount intCount=0
' Object creation ' *************** Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload ' ****** mySmartUpload.Upload
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>") %> </BODY> </HTML>
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>")
' Sender en mail til administratoren med fil infos dim body, adminEmail adminEmail = "din email"
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>")
' Sender en mail til administratoren med fil infos dim body, adminEmail adminEmail = "din email"
<% ' Variables ' ********* Dim mySmartUpload Dim file Dim intCount intCount=0 dim body body = "En bruger har uploadet disse filer:"&vbcrlf ' Object creation ' *************** Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") mySmartUpload.AllowedFilesList = "GIF,JPG" mySmartUpload.MaxFileSize = 100000
' Upload ' ****** mySmartUpload.Upload
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>")
' Sender en mail til administratoren med fil infos dim adminEmail adminEmail = "din email" set msg = Server.CreateObject("JMail.Message") msg.logging = true msg.From = "<domæne email>" msg.FromName = "Fx dit domæne" msg.AddRecipient adminEmail msg.Subject = "fx. Upload fra bruger" msg.Body = body msg.Send( "mail.domæne") %> </BODY> </HTML>
Jeg vil meget gerne sætte den op til 100 point hvis du kan hjælpe med en sidste detalje som er, at brugerne bliver sendt til en ny side, hvis der f.eks. er fejl, pga. fokert filtype eller størrelse ect...
lige nu for de bare en asp fejl med forkert type.
den nye side kan jeg lave selv, hvor jeg bare skriver at check filtypen eller noget andet. f.eks kan siden hedde fejl.html eller fejl.asp
Du kan prøve den her, jeg har ikke testet den endnu. Den skriver til brugeren hvis der er en fejl, og hvilken fil den ikke kunne uploade. Men har som sagt ikke testet det endnu.
<HTML> <BODY BGCOLOR="white">
<H1>Upload</H1> <HR>
<% ' Variables ' ********* Dim mySmartUpload Dim file Dim intCount intCount=0 dim body, errorMsg, wasError wasError = false errorMsg = "Der skete en fejl i upload, nogle filer er muligvis ikke uploadet check om filerne overholder kravene (type, størrelse)" body = "En bruger har uploadet disse filer:"&vbcrlf ' Object creation ' *************** On Err resume next Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") mySmartUpload.AllowedFilesList = "GIF,JPG" mySmartUpload.MaxFileSize = 100000
' Upload ' ****** mySmartUpload.Upload
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the properties of the current file ' ***************************************** if Err then errorMsg = errorMsg & "<BR>"&file.Name&" kunne ikke uploades" wasError = true Else body = body & "Name = " & file.Name & vbcrlf &_ "Size = " & file.Size & vbcrlf &_ "FileName = " & file.FileName & vbcrlf &_ "FileExt = " & file.FileExt & vbcrlf &_ "FilePathName = " & file.FilePathName & vbcrlf &_ "ContentType = " & file.ContentType & vbcrlf &_ "ContentDisp = " & file.ContentDisp & vbcrlf &_ "TypeMIME = " & file.TypeMIME & vbcrlf &_ "SubTypeMIME = " & file.SubTypeMIME & vbcrlf intCount = intCount + 1 End IF End If Next If wasError then Response.Write errorMsg End If Response.Write Replace(body,vbCrlF,"<BR>") ' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>")
' Sender en mail til administratoren med fil infos dim adminEmail adminEmail = "din email" set msg = Server.CreateObject("JMail.Message") msg.logging = true msg.From = "<domæne email>" msg.FromName = "Fx dit domæne" msg.AddRecipient adminEmail msg.Subject = "fx. Upload fra bruger" msg.Body = body msg.Send( "mail.domæne") %> </BODY> </HTML>
<% ' Variables ' ********* Dim mySmartUpload Dim file Dim intCount intCount=0 dim body, errorMsg, wasError wasError = false errorMsg = "Der skete en fejl i upload, nogle filer er muligvis ikke uploadet check om filerne overholder kravene (type, størrelse)" body = "En bruger har uploadet disse filer:"&vbcrlf ' Object creation ' *************** On Err resume next Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") mySmartUpload.AllowedFilesList = "GIF,JPG,BMP" mySmartUpload.MaxFileSize = 100000
' Upload ' ****** mySmartUpload.Upload
' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' ************************************************************************** file.SaveAs("/files/" & file.FileName) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName)
' Display the properties of the current file ' ***************************************** body = body & "Name = " & file.Name & vbcrlf &_ "Size = " & file.Size & vbcrlf &_ "FileName = " & file.FileName & vbcrlf &_ "FileExt = " & file.FileExt & vbcrlf &_ "FilePathName = " & file.FilePathName & vbcrlf &_ "ContentType = " & file.ContentType & vbcrlf &_ "ContentDisp = " & file.ContentDisp & vbcrlf &_ "TypeMIME = " & file.TypeMIME & vbcrlf &_ "SubTypeMIME = " & file.SubTypeMIME & vbcrlf intCount = intCount + 1 End If Next If Err then Response.Write errorMsg wasError = true End If Response.Write Replace(body,vbCrlF,"<BR>") ' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>")
' Sender en mail til administratoren med fil infos If intCount > 0 then dim adminEmail adminEmail = "din email" set msg = Server.CreateObject("JMail.Message") msg.logging = true msg.From = "<domæne email>" msg.FromName = "Fx dit domæne" msg.AddRecipient adminEmail msg.Subject = "fx. Upload fra bruger" msg.Body = body msg.Send( "mail.domæne") End If %> </BODY> </HTML>
Kan jeg smide et felt ind, som gør at den ikke skal sende email hvis filer = 0 ?
altså hvos der ikke er uploadet noget, for jeg kunne da godt forestille mig nogle syntes det ville være skide skægt at sidde og trykke send send send 100 gange *GGG*
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.