IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

uploader un fichier sur un serveur web distant


Sujet :

ASP.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2008
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 97
    Par défaut uploader un fichier sur un serveur web distant
    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

  2. #2
    Membre expérimenté
    Avatar de zooffy
    Homme Profil pro
    Chef de projet MOA
    Inscrit en
    Août 2004
    Messages
    3 895
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Chef de projet MOA
    Secteur : Bâtiment

    Informations forums :
    Inscription : Août 2004
    Messages : 3 895
    Par défaut
    As tu vérifié que le chemin qu'il te propose est bien valide sur le serveur ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2008
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 97
    Par défaut
    Effectivement zooffy, le problème venait du chemin!

    Merci pour ton aide

    Tommy

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 28/01/2009, 12h58
  2. Réponses: 1
    Dernier message: 05/06/2007, 08h57
  3. [Upload] Upload de fichier sur le serveur
    Par jbr_85 dans le forum Langage
    Réponses: 4
    Dernier message: 07/02/2007, 16h55
  4. Réponses: 3
    Dernier message: 20/04/2006, 23h21
  5. Upload de fichier sur le serveur
    Par krfa1 dans le forum ASP
    Réponses: 9
    Dernier message: 29/11/2005, 13h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo