|
|
Vous êtes ici : Forums > Langage ASP > Problème avec AspSmartUpload
Problème avec AspSmartUpload
Bonjour, j'utilise le composant AspSmartUpload pour permettre à l'utilisateur de charger des fichiers à partir d'un formulaire. Cela fonctionne, mais les restrictions au niveau des fichiers à charger (uniquement .doc et .zip) ne marche pas. Il me charge tous les types de fichier. J'ai joint le fichier asp contenant le code
Merci P.s voici le code de la page asp <% function Modify_String_for_SQL(byVal stringtocheck) pos_apo_tmp = 1 long_chaine = Len(stringtocheck) pos_apo = Instr(stringtocheck,"'") Do while pos_apo <> 0 stringtemp = stringtemp & Mid(stringtocheck,pos_apo_tmp,(pos_apo-pos_apo_tmp + 1)) & "'" pos_apo_tmp = pos_apo+1 pos_apo = Instr((pos_apo+2),stringtocheck,"'") Loop stringtemp = stringtemp & right(stringtocheck,(long_chaine - (pos_apo_tmp-1))) Modify_String_for_SQL = stringtemp end function
' Variables ' ********* Dim mySmartUpload Dim intCount Dim Conn Dim SQL Dim Rs Dim file Dim thenum Dim i Dim thenom Dim theprenom Dim theemail DIm thenomarticle DIm theversion Dim fso Dim up
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
connstring="DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & Server.MapPath(".") & "/../admin/ems07.mdb" conn.Open connstring
Set mySmartUpload = Server.CreateObject("Persits.Upload.1")
mySmartUpload.SetMaxSize 2000000, True mySmartUpload.IgnoreNoPost = True mySmartUpload.SaveVirtual "../Upload/"
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.AllowedFilesList = "doc,zip" mySmartUpload.DeniedFilesList = "psd" mySmartUpload.DenyPhysicalPath = True mySmartUpload.MaxFileSize = 2000000 mySmartUpload.Upload
For Each toto in mySmartUpload.Files
up = toto.FileName thenum = mySmartUpload.form("num") thenomarticle = mySmartUpload.Form("nomarticle") thenom = mySmartUpload.form("nomdepositaire") theprenom = mySmartUpload.form("prenomdepositaire") theemail = mySmartUpload.Form("emaildepositaire") thelog = mySmartUpload.Form("login") thepass = mySmartUpload.Form("password") theversion = mySmartUpload.Form("version")+1
nomfichier = thenum&"_"&thenom&"_"&day(date)&"_"&month(date)&"_"&year(date)&"(V"&theversion&")"&toto.Ext
sql = "SELECT * from upload where num = " & thenum Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 1, 3
theoldfichier= rs("fichier")
If Error Then
Response.Write("<b>Erreur : </b><br>Votre fichier n'est pas du bon <b>type ou <br>Votre fichier dépasse la taille autorisée (2 Mo)<br> Cliquer sur précédent dans votre navigateur")
else
'************************ MAJ Nom du fichier et de la Date *******************************************************
SQL = "UPDATE upload SET fichier='"&Modify_String_for_SQL(nomfichier)&"',datearticle='"&Modify_String_for_SQL(date())&"',version='"&Modify_String_for_SQL(theversion)
SQL= SQL & "' WHERE num = " & thenum
conn.Execute(SQL)
'************************ Suppression du 1er fichier *******************************************************
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
dir = Server.MapPath("../") if FSO.FileExists(dir &"\upload\" & theoldfichier) then set filePt = FSO.getFile(dir & "\upload\" & theoldfichier) filePt.delete end if
if FSO.FileExists(dir &"\upload\" & up) then set filePt2 = FSO.getFile(dir &"\Upload\" & up) filePt2.Move dir &"\Upload\" & nomfichier end if
fso.close set fso=nothing
'************************ Envoi mail au depositaire ************************************************************
Set JMail = Server.CreateObject("Persits.MailSender")
' Ne pas toucher ce parametre adresse du serveur SMTP JMail.Host = "smtp.internet-fr.net"
Subject = "EMSLIBS-2007 - Communication"
' Ne pas toucher ces parametres adresse du demandeur et sujet du mail defini ci dessus JMail.From = "abstract@emslibs.com" JMail.Subject = Subject
' Modifier ce parametre adresse du destinataire JMail.AddBCC theemail JMail.Body = body
'codage type html JMail.IsHTML = True
'définition du corp du texte Dim Ct Ct="<html>" ct=ct&"<body>" Ct = ct&"<p>Bonjour,</p><p>Votre fichier a bien été enregistré correctement. Ci joint un rappel de votre login et votre mot de passe qui <br> vous seront nécessaires si vous devez encore apporter des modifications à votre résumé </p><p>Login : <b>"& thenom &"</b></p><p>Password : <b>"& theprenom & "</b></p><p>A bientôt sur notre site (<a href=www.emslibs.com>www.emslibs.com</a>)</p>" Ct=ct&"</body>" ct=ct&"</html>" JMail.Body = ct
JMail.Priority = 3
JMail.Send
session("nomfichier")=nomfichier session("thenom")=thenom session("theprenom")=theprenom session("thenomarticle")=thenomarticle
end if 'on error resume next
Next
'Fermeture des objets créés
response.redirect ("revuemailems.asp") %>
Message posté le 25/10/2006
par nicolasferraris
Répondre à ce message |
|
|

|
A RETENIR CETTE SEMAINE |
06/10/2008 -
Un sursis de six mois pour Windows XP
Les constructeurs pourront continuer à proposer ce système d’exploitation jusqu’en juillet 2009 ...
|
06/10/2008 -
Windows Seven déjà préféré à Vista
Une étude réalisée auprès de responsables informatiques de grandes entreprises montre à quel point V ...
|
06/10/2008 -
Anders Heljberg raconte C# et évoque C#4
Dans cette très belle interview du magazine ComputerWorld, le papa de C#, Anders Hejlsberg, révèle p ...
|
06/10/2008 -
Miramar Crouesty dévoile ses atouts en Silverlight 2
20 jours seulement ont suffi à l'équipe de DotVision pour développer ce magnifique site Internet ric ...
|
03/10/2008 -
Apprenez rapidement à utiliser ITextSharp pour la création de vos PDF
TextSharp est une librairie open-source en C# adaptée depuis iText par Gerald Henson permettant la c ...
|
02/10/2008 -
Contrôlez Outlook avec MAPI Extended au sein de vos applications .Net
Dans cet article, vous allez apprendre comment implémenter une librairie C++ qui aidera à utiliser l ...
|
02/10/2008 -
CodeS-SourceS vous propose un sondage
CodeS-SourceS sollicite quelques minutes de votre temps pour participer à une enquête sur vos usages ...
|
|
|