Bonjour, je développe en asp.
Voila : je propose de uploader un fichier.Une fois que le serveur l'a récupéré, son chemin d'acces complet et stocké dans la variable FilePath.
J'affecte ensuite son nom à la variable fichier.
Là tout se passe à merveille.
Mais lorsque je veux ouvrir ce fichier , j'affecte à la propriété Path de la méthode MapPath la variable fichier et là ca coince...
Voila l'erreur fournie par mon navigateur :
Type d'erreur :
Server.MapPath(), ASP 0171 (0x80004005)
Le paramètre Path doit être spécifié pour la méthode MapPath.
Et voila mon code asp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
dim fichier
'fichier=""""&FilePath&""""
EndIf
%>
<hr>
<br>
<%
fichier = GetFileName(FilePath)
'Separation du nom de fichier du chemin-----------------------
Function GetFileName(FullPath)
Dim Pos, PosF
PosF =0
For Pos = Len(FullPath)To1Step-1
SelectCase Mid(FullPath, Pos, 1)
Case "/", "\": PosF = Pos + 1: Pos = 0
EndSelect
Next
If PosF =0Then PosF =1
GetFileName = Mid(FullPath, PosF)
EndFunction
%>
voilouuu :<%=fichier%>
<br><hr><br><br>
<%'ouverture du fichier--------------------------------------%>
<%
dim objOpenFile, objFSO, strPath, S, s1 ,S2,S3
strPath = Server.MapPath(fichier)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objOpenFile = objFSO.OpenTextFile(strPath, 1)
S = objOpenFile.ReadAll
response.write S
%>
Merci pour votre aide