Je travaille récemment sur un site de musique, c'est un fichier musical. . . Il est généralement collecté sur Internet. . donc. . Une procédure de collecte a été écrite.
La copie de code est la suivante:
<%
Onerrorresumenext
CONSUPLOADPATH = "/ Uploads /" 'Chemin de stockage de fichiers
Constallowfileext = "jpg, wma, swf, gif" 'autorisé à être collectés
'Constallowfilesize = "200"
FunctionGetFile (URL)
Ifurl = "" alors
Sortie
Autre
url = garniture (URL)
Endire
'Obtenez le fichier
fileExt = lCase (mid (URL, instrrev (url, ".") + 1)) 'type de fichier
filename = lCase (mid (URL, instrrev (URL, "/") + 1, instrrev (URL, ".") - instrrev (URL, "/") - 1)) 'Aucun nom de fichier Nom de fichier de fichier
newFilePath = getNow ("Date") & "_" & remplacer (FormatDateTime (Now (), 3), ":", "") & "_" & CleanFileName (FileName) & "." & fileXt
iFinstr ("," & lcase (allowFileExt) & ",", ",", "& filext &", ") = 0The
getFile = "type de fichier non autorisé"
Sortie
Endire
Setxmlhttp = server.createObject ("Microsoft.xmlhttp")
xmlhttp.open "Get", URL, faux
xmlhttp.send
'Whilexmlhttp.readystate <> 4
'xmlhttp.waitforResponse1000
'Wend
Ifxmlhttp.status <> 200Then
getFile = "Erreur d'obtention du fichier"
Sortie
Autre
SetFolder = server.createObject ("scripting.fileSystemObject")
Nom de dimle
FolderName = getNow ("année") & getNow ("mois") 'Folder'
Ifffolder.folderexists (server.mappath (uploadpath)) = falsethhen
dossier.createfolderserver.mappath (uploadpath)
Endire
Ifffolder.folderexists (server.mappath (uploadpath & foldername)) = falsethhen
dossier.createfolderserver.mappath (uploadpath & foldername)