tags:

views:

82

answers:

2

On my website I have a .php script to which our customers can post orders.

  $destname = CreateUniqueOrderFileName();
  if (is_uploaded_file($_FILES['file']['tmp_name'])) {
    if (move_uploaded_file($_FILES['file']['tmp_name'], $destname))         
      echo "OK";
    else 
      echo "ERROR: move";                  
  }

So for my clients I wrote an app in C# and if I upload an order I do something like this:

var client = new WebClient();
byte[] response = client.UploadFile("http://mywebsite/order.php", "POST", orderFile);

But now I have a customer who uses Oracle and wants to post an order using PL/SQL. I try to tell him he has to do a file uploaded via HTTP POST and use multipart/form-data but he does not understand me. Maybe I'm using the wrong vocabulary or not using standards.

So does someone have an example of how to post a file to a .php script in PL/SQL or a suggestion where to find more information uploading a file to a .php webpage with an Oracle client.

+2  A: 

I think you can use PL/SQL package UTL_HTTP to do a HTTP POST

http://awads.net/wp/2005/11/30/http-post-from-inside-oracle/

Another option might be to use a Java Stored Procedure

Robert Merkwürdigeliebe
+1  A: 

We could find a way to do a POST request using the Content-Type multipart/form-data according to RFC2388. So I changed the .php script to something like this.

   $fp = fopen('php://input','r');
   $content = stream_get_contents($fp);
   $destname = CreateUniqueOrderFileName();
   $isWritten = @file_put_contents($destname, $content); 
   if($isWritten===false)
   {
     echo "ERROR: could not write file: ".$destname;    
     return;       
   }

Using this we where able to post the order using the UTL_HTTP lib to do a HTTP POST.

Bas Jansen