Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To be more clear I have posted both the server.php code and client.php code. Please see below:</p> <h1>## server.php ##</h1> <pre><code>require_once('lib/nusoap.php'); //include required class for build nnusoap web service server // Create server object $server = new soap_server(); // configure WSDL $server-&gt;configureWSDL('Upload File', 'urn:uploadwsdl'); // Register the method to expose $server-&gt;register('upload_file', // method array('file' =&gt; 'xsd:string','location' =&gt; 'xsd:string'), // input parameters array('return' =&gt; 'xsd:string'), // output parameters 'urn:uploadwsdl', // namespace 'urn:uploadwsdl#upload_file', // soapaction 'rpc', // style 'encoded', // use 'Uploads files to the server' // documentation ); // Define the method as a PHP function function upload_file($encoded,$name) { $location = "uploads\\".$name; // Mention where to upload the file $current = file_get_contents($location); // Get the file content. This will create an empty file if the file does not exist $current = base64_decode($encoded); // Now decode the content which was sent by the client file_put_contents($location, $current); // Write the decoded content in the file mentioned at particular location if($name!="") { return "File Uploaded successfully..."; // Output success message } else { return "Please upload a file..."; } } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server-&gt;service($HTTP_RAW_POST_DATA); </code></pre> <p>=====================================================================</p> <h1>## client.php ##</h1> <pre><code>require_once('lib/nusoap.php'); //include required class for build nnusoap web service server $wsdl="http://localhost:81/subhan/webservice3/server.php?wsdl"; // SOAP Server if($_POST['submit']) { $tmpfile = $_FILES["uploadfiles"]["tmp_name"]; // temp filename $filename = $_FILES["uploadfiles"]["name"]; // Original filename $handle = fopen($tmpfile, "r"); // Open the temp file $contents = fread($handle, filesize($tmpfile)); // Read the temp file fclose($handle); // Close the temp file $decodeContent = base64_encode($contents); // Decode the file content, so that we code send a binary string to SOAP } $client=new soapclient($wsdl) or die("Error"); // Connect the SOAP server $response = $client-&gt;__call('upload_file',array($decodeContent,$filename)) or die("Error"); //Send two inputs strings. {1} DECODED CONTENT {2} FILENAME // Check if there is anny fault with Client connecting to Server if($client-&gt;fault){ echo "Fault {$client-&gt;faultcode} &lt;br/&gt;"; echo "String {$client-&gt;faultstring} &lt;br/&gt;"; } else{ print_r($response); // If success then print response coming from SOAP Server } &lt;form name="name1" method="post" action="" enctype="multipart/form-data"&gt; &lt;input type="file" name="uploadfiles"&gt;&lt;br /&gt; &lt;input type="submit" name="submit" value="uploadSubmit"&gt;&lt;br /&gt; &lt;/form&gt; </code></pre> <p>=================================================</p> <p>All you need to do is download the nusoap.php which will be seen in soap library <a href="http://sourceforge.net/projects/nusoap/">http://sourceforge.net/projects/nusoap/</a></p> <p>This is fully tested and it will 100% work without fail.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload