Solved

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

Posted on 2010-09-02
3
955 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:sigmatec_pk
  • 2
3 Comments
 
LVL 6

Expert Comment

by:youssefomar
ID: 33603332
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

0
 
LVL 6

Expert Comment

by:youssefomar
ID: 33603351
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

0
 

Accepted Solution

by:
sigmatec_pk earned 0 total points
ID: 33620601

<?php 

$docurl = curl_init(); 

curl_setopt($docurl, CURLOPT_SSL_VERIFYPEER, false); 

curl_setopt($docurl, CURLOPT_URL, "http://site.com/upload.php"); 

curl_setopt($docurl, CURLOPT_VERBOSE, 1); 

curl_setopt($docurl, CURLOPT_HEADER, 1); 

curl_setopt($docurl, CURLOPT_POST, 1); 

curl_setopt($docurl, CURLOPT_RETURNTRANSFER, 1); 

curl_setopt($docurl, CURLOPT_FOLLOWLOCATION, 1); 

curl_setopt($docurl, CURLOPT_POSTFIELDS, array("userfile"=>"{@picture.JPG}")); 

$webpage = curl_exec($docurl); 

echo "$webpage"; 

curl_close($docurl); 

?> 

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now