Jump to content

[ask] help to resolve this codes


ressaince

Recommended Posts

i have an ASP web services to change byte array that given from the client and change it to a file in IIS server

the code is like this :

 

[WebMethod]

        public string UploadFile(byte[] f, string fileName)

        {

           

            try

            {

               

                MemoryStream ms = new MemoryStream(f);

 

               

             

String path="/images/";

String location=HttpContext.Current.Server.MapPath(path);

FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(path)+fileName, FileMode.Create);

 

 

               

                ms.WriteTo(fs);

 

             

                ms.Close();

                fs.Close();

               

 

               

                return "OK";

            }

            catch (Exception ex)

            {

             

                return ex.Message.ToString();

            }

        }

 

i build the client in php

upload.php

<html>

<body>

<form action="action1.php" method="post" enctype="multipart/form-data">

Pilih File Anda:

<input type="file" name="myfile" />

<input type="submit" value="Upload" />

</form>

</body>

<html>

 

and

action1.php

<?php

require_once('nusoap.php');

$client = new nusoap_client('http://192.168.254.160/testuploadah/FileUploader.asmx?WSDL', 'wsdl','','', '', '');

$err = $client->getError();

if ($err) {

echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';

}

if(is_uploaded_file($_FILES['myfile']['tmp_name'])){

    $uploadFile = $_FILES['myfile'];

 

$params=array();

$params->f=????????

$params->filename=$_FILES['myfile']['name'];

 

$result = $client->call('UploadFile', $params,'', '', false, true);

if ($client->fault) {

echo '<h2>Fault</h2><pre>';

print_r($result);

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>';

print_r($result);

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.