Php 通过WinHTTP从Lotus Notes发送和接收文件

Php 通过WinHTTP从Lotus Notes发送和接收文件,php,lotus-notes,lotusscript,winhttprequest,Php,Lotus Notes,Lotusscript,Winhttprequest,我试图将一个文档文件从LotusScript发送到web服务器并保存在那里。不幸的是,文件传输不起作用。我有一个Lotusscript代理来获取文档,该部分正在工作。str_filecontent包含正确的xml文件,但文件传输或保存不起作用。这是我的Lotusscript代理: Option Public Option Declare Sub Initialize 'Declare long Dim lng_resolveTimeout, lng_connectTimeout

我试图将一个文档文件从LotusScript发送到web服务器并保存在那里。不幸的是,文件传输不起作用。我有一个Lotusscript代理来获取文档,该部分正在工作。str_filecontent包含正确的xml文件,但文件传输或保存不起作用。这是我的Lotusscript代理:

Option Public
Option Declare

Sub Initialize
    'Declare long
    Dim lng_resolveTimeout, lng_connectTimeout, lng_sendTimeout, lng_receiveTimeout As Long

    'Declare integer
    Dim int_serverCredentials As Integer

    'Declare variants
    Dim var_submitObject As Variant

    'Set values
    int_serverCredentials = 0

    lng_resolveTimeout = 120000 'miliseconds = 2 minutes
    lng_connectTimeout = 1200000
    lng_sendTimeout = 1200000
    lng_receiveTimeout = 1200000

    'Create HTTP object
    Set var_submitObject = CreateObject("WinHTTP.WinHTTPRequest.5.1")
    Call var_submitObject.SetTimeouts(lng_resolveTimeout, lng_connectTimeout, lng_sendTimeout, lng_receiveTimeout)

    'Standards for this post
    %REM
Content-Type: multipart/form-data; boundary={boundary}
{boundary}
Content-Disposition: form-data; name="data"; filename="{filename}"
Content-Type: text/plain
{contents}
{boundary}--
    %END REM
    Dim str_url As String
    str_url = "http://.../upload.php"
    Dim str_AUTH As String
    Dim str_boundary As String
    Dim str_filecontent As String

    str_filecontent = get_data()
    Dim submitHTTP
    'Set post parameters
    Call var_submitObject.open("POST", str_url, False)
    Call var_submitObject.setRequestHeader("Accept", "application/xml")
    Call var_submitObject.setRequestHeader("Authorization", "Basic " & str_auth)
    Call var_submitObject.setRequestHeader("Content-Type", "multipart/form-data; boundary=b1")
    str_boundary = |--b1| & Chr(13) & Chr(10) &_
|Content-Disposition: form-data; name="data"; filename="name.txt"| & Chr(13) & Chr(10) &_
|Content-Type: text/plain| & Chr(13) & Chr(10) &_
    str_fileContent & |b1--|
    'Send the HTTP request
    Call var_submitObject.Send(str_boundary)
    'Wait for the answer and set object as returned value for further validation
    Call var_submitObject.WaitForResponse
    Set submitHTTP = var_submitObject
    'Clear memory
    Set var_submitObject = Nothing
End Sub

%REM
    Function get_data
    Description: Comments for Function
%END REM
Function get_data() As String
    Dim session As New NotesSession
    Dim doc As NotesDocument
'   Dim db As NotesDatabase
    Dim exporter As NotesDXLExporter
'   Set db = session.CurrentDatabase
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set uidoc = workspace.CurrentDocument
    Set doc = uidoc.Document
'   Set doc = SESSION.CU
    Set exporter = session.CreateDXLExporter
    get_data = exporter.Export(doc)
    Print get_data
End Function
以下是接收和保存文件的web服务器PHP:

<?php

define("UPLOAD_DIR", "/temp/");

if (!empty($_FILES["data"])) {
    $myFile = $_FILES["data"];

    if ($myFile["error"] !== UPLOAD_ERR_OK) {
        echo "<p>An error occurred.</p>";
        exit;
    }

    // preserve file from temporary directory
    $success = move_uploaded_file($myFile["tmp_name"],
        UPLOAD_DIR . $name);
    if (!$success) {
        echo "<p>Unable to save file.</p>";
        exit;
    }

    // set proper permissions on the new file
    chmod(UPLOAD_DIR . $name, 0644);
}
?>

谢谢你的时间

您从传输中得到了什么错误?当我从Lotus Notes运行代理时,它运行时没有错误。问题是,即使应该调用my upload.php,也没有调用它。