开发者

Post a file to a .php page from Oracle

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 WebClie开发者_运维技巧nt();
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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜