begin process at 2012 05 27 07:27:44
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Fichiers/Disque

 > SERVER.MAPPATH QUI ACCEPTE LES ../

SERVER.MAPPATH QUI ACCEPTE LES ../


 Information sur la source

Note :
2 / 10 - par 2 personnes
2,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Fichiers/Disque Classé sous :servermappath Niveau :Débutant Date de création :27/03/2007 Date de mise à jour :27/03/2007 21:51:53 Vu :9 339

Auteur : divlys

Ecrire un message privé
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

le Server.mapPath ne gère pas les "../"
après de longue recherche sur le net, j'ai décidé d'écrire moi même la petite fonction adéquate cela prend parfois moins de temps que de chercher!

Elle rend le vide si le lien est vide
elle rend la même chose que Server.mapPath s'il ne contient pas de ".."
et rend le chemin correcte sinon.
Elle remplace aussi les "/" par "\" à remplacer si vous le souhaitez

Source

  • function findPath(path)
  • path = replace(path,"/","\")
  • if InStr(path,"..\") = 0 then
  • if path >< "" then
  • findPath = Server.mapPath(path)
  • else
  • findPath = ""
  • end if
  • exit function
  • end if
  • findPath = Server.mapPath(".")
  • do until InStr(path,"..\") = 0
  • path = replace(path,"..\","",1,1)
  • findPath = Left(findpath, InStrRev(findpath, "\")-1)
  • loop
  • findPath = findPath&"\"&path
  • end function
function findPath(path)
	path = replace(path,"/","\")
	if InStr(path,"..\") = 0 then
		if path >< "" then
			findPath = Server.mapPath(path)
		else 
			findPath = ""
		end if
		exit function
	end if
	findPath = Server.mapPath(".")
	do until InStr(path,"..\") = 0 
		path = replace(path,"..\","",1,1)
		findPath = Left(findpath, InStrRev(findpath, "\")-1)
	loop
	findPath = findPath&"\"&path
end function



 Historique

27 mars 2007 21:51:53 :
rien d'important, j'ai juste mis retirer les <%%>

 Sources de la même categorie

Source .NET (Dotnet) IMPORTER UN FICHIER EXCEL DEPUIS UN POSTE ET L'AJOUTER SUR L... par jseblavoie
UPLOAD D'IMAGES VIA ADODB.STREAM ET SQL SERVER par Nicolas_kojack
LISTING DE FICHIERS ET RÉPERTOIRES (FONCTION RÉCURSIVE) par Warwick
Source avec Zip UTILITAIRE POUR FORCER LE TÉLÉCHARGEMENT D'UN FICHIER SUR UN... par shaiulud
Source .NET (Dotnet) .NET - CLASSE DE LOG D'EVÈNEMENT par fabrice69

Commentaires et avis

Commentaire de motemape le 07/11/2008 17:51:17

Tres superb :)

J'ai cherché cette formule depuis longtemps, et VOILA!!!!
Tout marche tres bien maintenant

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,593 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales