Bonjour à tous,

voilà mon soucis!

J'ai developpé une appli permettant d'affecter une image à un produit via le control FileUpload.

En local, tout fonctionne très bien!

Mais comme je le craignais, une fois l'appli sur le serveur web, rien ne va plus, je reçois le message suivant :
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
35
36
37
38
39
40
41
42
43
44
45
 
Server Error in '/' Application.
Could not find a part of the path 'E:\kunden\homepages\5\d258871681\photos\bag ancienne.jpg'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\kunden\homepages\5\d258871681\photos\bag ancienne.jpg'.
 
Source Error:
 
Line 158:
Line 159: ' On sauvegarde le fichier sur le disque et on fixe la valeur du paramètre PhotoPath
Line 160: PhotoUpload.SaveAs(Server.MapPath(PhotosPath))
Line 161: Return PhotosPath
Line 162: Else
 
 
Source File: E:\kunden\homepages\5\d258871681\berg\appli\AjoutProd.aspx.vb Line: 160
 
Stack Trace:
 
[DirectoryNotFoundException: Could not find a part of the path 'E:\kunden\homepages\5\d258871681\photos\bag ancienne.jpg'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +193
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61
System.IO.FileStream..ctor(String path, FileMode mode) +55
System.Web.HttpPostedFile.SaveAs(String filename) +99
System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23
AjoutProd.ProcessPhotoUpload(FileUpload PhotoUpload, Boolean CancelOperation) in E:\kunden\homepages\5\d258871681\berg\appli\AjoutProd.aspx.vb:160
AjoutProd.ListProd_RowUpdating(Object sender, GridViewUpdateEventArgs e) in E:\kunden\homepages\5\d258871681\berg\appli\AjoutProd.aspx.vb:201
System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +133
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +720
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
 
 
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
Voici le code que j'utilise en local

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
35
36
37
38
PrivateFunction ProcessPhotoUpload _
(ByVal PhotoUpload As FileUpload, ByVal CancelOperation AsBoolean) AsString
CancelOperation = False' Par dfaut, on n'annule pas l'opration
If PhotoUpload.HasFile Then
' On s'assure que le fichier uploader est un jpg
' Paramtres() : strA()Type : System..::.String Premier String.
' strB()Type : System..::.String Deuxime String.
' ignoreCase() Type : System..::.Boolean
' Boolean indiquant une comparaison respectant ou non la casse. 
' (true indique une comparaison qui ne respecte pas la casse.)
IfString.Compare(System.IO.Path.GetExtension(PhotoUpload.FileName), _
".jpg", True) <> 0 Then
UploadWarning.Text = _
"Seul un fichier JPG (image ou photo) peut-tre utilis pour la photo du produit."
UploadWarning.Visible = True
CancelOperation = True
ReturnNothing
EndIf
Const PhotosDirectory AsString = "~/photos/"
Dim PhotosPath AsString = PhotosDirectory + PhotoUpload.FileName
Dim fileNameWithoutExtension AsString = _
System.IO.Path.GetFileNameWithoutExtension(PhotoUpload.FileName)
Dim iteration AsInteger = 1
While System.IO.File.Exists(Server.MapPath(PhotosPath))
PhotosPath = String.Concat(PhotosDirectory, _
fileNameWithoutExtension, "-", iteration, ".jpg")
iteration += 1
EndWhile
' On sauvegarde le fichier sur le disque et on fixe la valeur du paramtre PhotoPath
PhotoUpload.SaveAs(Server.MapPath(PhotosPath))
Return PhotosPath
Else
' Aucun fichier uploader
ReturnNothing
EndIf
EndFunction
J'imagine bien que le problème vient de la manière dont je compose mon chemin d'accès, mais sur un serveur web distant, je ne sais pas comment faire!
Faut-il également utiliser les identifiants connexions au site distant? Ou le fait que l'appli y soit hébergée suffit à autoriser la page à uploader le fichier?

Si quelqu'un pouvait me filer un tuyau, cela me sortirai une belle épine du pied car je tourne en rond depuis un bon moment.

Merci,
Tommy