Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6942251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:59:28+00:00 2026-05-27T12:59:28+00:00

I am trying to upload a text file of data to a soap server

  • 0

I am trying to upload a text file of data to a soap server with a function called BulkLoadContacts. The request requires a value called

<ImportFileStream>base64Binary</ImportFileStream>

I am creating a file, then querying my database, writing to the file, then connecting to their soap server, then sending my request.

Here is a snippit of my code:

    $file = 'tempfile.txt';
$handle = fopen($file, 'w') or die ('Cannot open file: ' . $file);

$list = dbExec("select * from listrak_upload");


foreach ($list as $l){

    $data = $l['email'] . "|" . $l['First_Name'] . "|" . $l['Last_Name'];

    fwrite($handle, $data);
}
$ap_param = array( 
    'ListID'    => (integer) 252403,
    'WSImportDirectives'    => array(
        'ImportTypeEnum'        => 'AddSubscribers',
        'ImportProfileTypeEnum' => 'Overwrite',
        'FileName'              => '',
        'HasColumnNames'        => true,
        'FileName'              => $file,
        'FileDelimiter'         => '|',
    ),
    'fileMappings'  => array(
        'WSFileMappings'    => array(
            'FileColumn'            => 0,
            'IsEmailAddressColumn'  => true,
            'AttributeID'           => 'email',
        ),
),
        'ImportFileStream' => $handle
    );

try {
    $return = $soapClient->__soapCall("BulkLoadContacts",array('parameter' => $ap_param));
    var_dump($return);
}
catch(SoapFault $fault){
    var_dump($fault);
}

Here is a code example from the documentation:

Byte[] fileBytes = System.IO.File.ReadAllBytes("C:\\Temp\\ImportFiles\\TestImportFileWithProfile.txt");

Any ideas how to do this in PHP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:59:28+00:00Added an answer on May 27, 2026 at 12:59 pm

    Maybe something like this:

    $fileName = "test.txt";
    $rawFile = fread(fopen($fileName, "r"), filesize($fileName));
    $B64File = base64_encode($rawFile)
    

    In the param array:

    'ImportFileStream' => $B64File
    

    Maybe PHP client SOAP engine encodes to B64 automatically. If this is the case, comment $B64File = base64_encode($rawFile) and send $rawFile instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to upload file(s) using PrototypeJs request method but I failed. The
I am trying to use a textreader to retrieve data from a text file
I'm trying to implement file upload functionality in the iPhone app. Server code is
I'm trying to upload a PNG file through Winsock2 HTTP Post. Here's my request
I'm trying to upload a multi-line text file to be GeoCoded by BING. 1,en-US,,16630
I am trying to upload an Excel file onto my server. There is one
I'm trying to upload a file using Watin and C#. Under Windows XP, Watin
I am trying to upload a file from a flash widget to my rails
I'm trying to upload an MP3 file (using the paperclip plugin) and then read
I'm trying to upload a huge file from my Nokia N95 mobile to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.