i have an ASP web services to change byte array that given from the client and change it to a file and save it in the web server
the code is like this :

        public string UploadFile(byte[] f, string fileName)
                MemoryStream ms = new MemoryStream(f);

            String path="/myfile/";
            String location=HttpContext.Current.Server.MapPath(path);
             FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(path)+fileName, FileMode.Create);


                return "OK";
            catch (Exception ex)
                return ex.Message.ToString();

the web services need byte array and file name..
i build the client in php

<form action="action1.php" method="post" enctype="multipart/form-data">
 Pilih File Anda:
<input type="file" name="myfile" />
<input type="submit" value="Upload" />

and action1.php the code is:

$client = new nusoap_client('', 'wsdl','','', '', '');
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    $uploadFile = $_FILES['myfile'];
////how can read byte array of $uploadFile so i can send to web services???
////are php can only send string to web services????

$result = $client->call('UploadFile', $params,'', '', false, true);
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
echo '</pre>';
} else {
 //Check for errors
$err = $client->getError();
if ($err) {
//// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
//// Display the result
echo '<h2>Result</h2><pre>';
echo '</pre>';

how can i Send the byte array parameter to the web services,so the web services can started????

i still can resolve this problem,the web services always return an error because i can't send byte array

Recommended Answers

In php the main part is you will have to receive byte array to save as file and also you need to return the same byte array data through file_get_contents.

$GLOBALS will return the Byte_Array data posted from client.

If you will read these tutorials, you will get …

Jump to Post

All 2 Replies

read the file like :-
$byteArr = fread(fopen($_FILES, "r"), filesize($_FILES));

and than wrap the byteArr into base64encode like below :-


This will work surely.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.