Solved

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

Posted on 2010-09-02
3
959 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hbo knew my windows software 4 62
Split wordpress loop 35 56
Link failure 16 34
Inserting results of While loop to sql server 5 18
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

838 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