2017-06-06 1 views
0

J'ai une application ASP classique qui est actuellement déployée sur le serveur A. J'ai une fonctionnalité de "téléchargement de pièces jointes" par laquelle j'essaye de télécharger des fichiers sur le serveur A (où mon application ASP est déployée dans IIS) elle-même en utilisant ci-dessous du code ASP classique. Lorsque j'essaie de télécharger des fichiers sur le serveur A, mes fichiers sont téléchargés avec succès et rapidement. Mais, lorsque j'essaie de télécharger le fichier sur un autre serveur B, je ne peux pas télécharger de fichiers en utilisant le même code ASP de l'utilitaire. Ma question est mon application déployée sur le serveur A et j'ai besoin de télécharger un fichier via l'application au serveur B. Est-ce possible? S'il vous plaît aider.Problème de téléchargement de fichier d'un serveur vers un autre serveur utilisant l'utilitaire de téléchargement ASP classique

Mon code actuel utilitaire fichier de téléchargement:

<% Class Loader 
Private dict 

Private Sub Class_Initialize 
    Set dict = Server.CreateObject("Scripting.Dictionary") 
End Sub 

Private Sub Class_Terminate 
    If IsObject(intDict) Then 
    intDict.RemoveAll 
    Set intDict = Nothing 
    End If 
    If IsObject(dict) Then 
    dict.RemoveAll 
    Set dict = Nothing 
    End If 
End Sub 

Public Property Get Count 
    Count = dict.Count 
End Property 

Public Sub Initialize 
    If Request.TotalBytes > 0 Then 
    response.write(Request.TotalBytes) 
    Dim binData 
     binData = Request.BinaryRead(Request.TotalBytes) 
     getData binData 
    End If 
End Sub 

Public Function getFileData(name) 
    If dict.Exists(name) Then 
    getFileData = dict(name).Item("Value") 
    Else 
    getFileData = "" 
    End If 
End Function 

Public Function getValue(name) 
    Dim gv 
    If dict.Exists(name) Then 
    gv = CStr(dict(name).Item("Value")) 

    gv = Left(gv,Len(gv)-2) 
    getValue = gv 
    Else 
    getValue = "" 
    End If 
End Function 

Public Function saveToFile(name, path) 
    If dict.Exists(name) Then 
    Dim temp 
     temp = dict(name).Item("Value") 
    Dim fso 
     Set fso = Server.CreateObject("Scripting.FileSystemObject") 
    Dim file 
    'File write Exception handling - David 
    On Error Resume Next 
    Set file = fso.CreateTextFile(path) 

    For tPoint = 1 to LenB(temp) 
     file.Write Chr(AscB(MidB(temp,tPoint,1))) 
    Next 
    file.Close 

    If Err.Number<>0 then 
     saveToFile = False 
    else 
     saveToFile = True 
    End if 
    On Error Goto 0 
    Else 
     saveToFile = False 
    End If 
End Function 

Public Function getFileName(name) 
    If dict.Exists(name) Then 
    Dim temp, tempPos 
     temp = dict(name).Item("FileName") 
     tempPos = 1 + InStrRev(temp, "\") 
     getFileName = Mid(temp, tempPos) 
    Else 
    getFileName = "" 
    End If 
End Function 

Public Function getFilePath(name) 
    If dict.Exists(name) Then 
    Dim temp, tempPos 
     temp = dict(name).Item("FileName") 
     tempPos = InStrRev(temp, "\") 
     getFilePath = Mid(temp, 1, tempPos) 
    Else 
    getFilePath = "" 
    End If 
End Function 

Public Function getFilePathComplete(name) 
    If dict.Exists(name) Then 
    getFilePathComplete = dict(name).Item("FileName") 
    Else 
    getFilePathComplete = "" 
    End If 
End Function 

Public Function getFileSize(name) 
    If dict.Exists(name) Then 
    getFileSize = LenB(dict(name).Item("Value")) 
    Else 
    getFileSize = 0 
    End If 
End Function 

Public Function getFileSizeTranslated(name) 
    If dict.Exists(name) Then 
    temp = LenB(dict(name).Item("Value")) 
     If temp <= 1024 Then 
     getFileSizeTranslated = temp & " bytes" 
     Else 
     temp = FormatNumber((temp/1024), 2) 
     getFileSizeTranslated = temp & " kilobytes" 
     End If 
    Else 
    getFileSizeTranslated = "" 
    End If 
End Function 

Public Function getContentType(name) 
    If dict.Exists(name) Then 
    getContentType = dict(name).Item("ContentType") 
    Else 
    getContentType = "" 
    End If 
End Function 




    Private Sub getData(rawData) 

Dim separator 

    separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1) 

Dim lenSeparator 
    lenSeparator = LenB(separator) 

Dim currentPos 
    currentPos = 1 
Dim inStrByte 
    inStrByte = 1 
Dim value, mValue 
Dim tempValue 
    tempValue = "" 

While inStrByte > 0 


    inStrByte = InStrB(currentPos, rawData, separator) 
    mValue = inStrByte - currentPos 

    If mValue > 1 Then 
    value = MidB(rawData, currentPos, mValue) 

    Dim begPos, endPos, midValue, nValue 
    Dim intDict 
     Set intDict = Server.CreateObject("Scripting.Dictionary") 

     begPos = 1 + InStrB(1, value, ChrB(34)) 
     endPos = InStrB(begPos + 1, value, ChrB(34)) 
     nValue = endPos 

    Dim nameN 
     nameN = MidB(value, begPos, endPos - begPos) 

    Dim nameValue, isValid 
     isValid = True 

     If InStrB(1, value, stringToByte("Content-Type")) > 1 Then 

     begPos = 1 + InStrB(endPos + 1, value, ChrB(34)) 
     endPos = InStrB(begPos + 1, value, ChrB(34)) 

     If endPos = 0 Then 
      endPos = begPos + 1 
      isValid = False 
     End If 

     midValue = MidB(value, begPos, endPos - begPos) 
      intDict.Add "FileName", trim(byteToString(midValue)) 

     begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:")) 
     endPos = InStrB(begPos, value, ChrB(13)) 

     midValue = MidB(value, begPos, endPos - begPos) 
      intDict.Add "ContentType", trim(byteToString(midValue)) 

     begPos = endPos + 4 
     endPos = LenB(value) 

     nameValue = MidB(value, begPos, ((endPos - begPos) - 1)) 
     Else 
     nameValue = trim(byteToString(MidB(value, nValue + 5))) 
     End If 

     If isValid = True Then 

     intDict.Add "Value", nameValue 
     intDict.Add "Name", nameN 

     dict.Add byteToString(nameN), intDict 
     End If 
    End If 

    currentPos = lenSeparator + inStrByte 
Wend 
     End Sub 

     End Class 

      Private Function stringToByte(toConv) 

Dim tempChar 

     For i = 1 to Len(toConv) 
     tempChar = Mid(toConv, i, 1) 
     stringToByte = stringToByte & chrB(AscB(tempChar)) 
Next 

     End Function 

    Private Function byteToString(toConv) 

       For i = 1 to LenB(toConv) 
       byteToString = byteToString & Chr(AscB(MidB(toConv,i,1))) 
       Next 
      End Function 
     %> 
+1

Je pense que vous n'avez pas le droit d'écriture sur le répertoire vous essayez de télécharger des fichiers, mais j'aurais besoin de plus d'informations. Quel message d'erreur obtenez-vous? – John

+0

Merci, pour la réponse. Mais, j'ai l'autorisation d'écriture sur le répertoire. Je reçois une erreur de dépassement de délai lors du téléchargement d'un fichier dont la taille est supérieure à 5 Mo environ. Mais si la taille du fichier est d'environ 1 Ko, il est téléchargé avec succès. – user1783170

Répondre

1

Probablement la taille de téléchargement par défaut à partir de Windows dans IIS: 196Kb ...

+0

Ceci ne fournit pas de réponse à la question. Une fois que vous avez suffisamment [réputation] (https://stackoverflow.com/help/whats-reputation) vous pourrez [commenter n'importe quel article] (https://stackoverflow.com/help/privileges/comment); Au lieu de cela, [fournissez des réponses qui ne nécessitent pas de précisions de la part du demandeur] (https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- je-fais-à la place). - [De l'examen] (/ review/low-quality-posts/18797006) – Patrick