Link to home
Start Free TrialLog in
Avatar of sigmatec_pk
sigmatec_pkFlag for Pakistan

asked on

how to send a multipart post (to send images) as a soap packet ?

Hi Everyone,

I want to upload images to some server using multipart post request. I am using PHP/cURL to send soap request envelopes

Any help would be very appreciated.

Amjad
Avatar of youssefomar
youssefomar
Flag of Libya image

Here is a sample of uploading 2 images, hopefully it will help:

You need to files, one to select the images ( select.html ) , and the other to upload them ( uploader.php )

// select.html
<html>

<bidy>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a files to upload:
<br/><input name="uploadedfile1" type="file" />
<br/><input name="uploadedfile2" type="file" />

<br/><input type="submit" value="Upload File" />
</form>
</body>
</html>




// uploader.php :
<?
$target_path = "/cb/web/htdocs/fileTest/uploads/";

for($i=1; $i<=2; $i++){
   $target_path = $target_path . basename( $_FILES['uploadedfile'.$i]['name']);
   if(move_uploaded_file($_FILES['uploadedfile'.$i]['tmp_name'], $target_path)) {
      echo "The file ".  basename( $_FILES['uploadedfile'.$i]['name'])." has been uploaded";
   }else{
      echo "There was an error uploading the file, please try again!";
   }
}

?>

Open in new window

a problem with the php code, use this one:

// uploader.php :
<?
$target = "/cb/web/htdocs/fileTest/uploads/";

for($i=1; $i<=2; $i++){
   $target_path = $target . basename( $_FILES['uploadedfile'.$i]['name']);
   if(move_uploaded_file($_FILES['uploadedfile'.$i]['tmp_name'], $target_path)) {
      echo "The file ".  basename( $_FILES['uploadedfile'.$i]['name'])." has been uploaded";
   }else{
      echo "There was an error uploading the file, please try again!";
   }
}

?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sigmatec_pk
sigmatec_pk
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial