#393: REST - PUT File Uploading
---------------------+------------------------------------------------------
 Reporter:  RossC0   |        Owner:  david    
     Type:  defect   |       Status:  new      
 Priority:  normal   |    Milestone:  0.11     
Component:  request  |      Version:  0.11.0RC1
 Severity:  major    |   Resolution:           
 Keywords:           |  
---------------------+------------------------------------------------------
Comment (by RossC0):

 Install HTTP_Request in pear and add the hacked file to the pear dir (no
 need to overwrite the original)

 To test a REST PUT just follow this example:
 {{{
 <?php
 error_reporting(E_ALL);
 require_once "HTTP/RequestPut.php";

 $req = new HTTP_Request("HTTP://-SOME-AGAVI-ACTION");

 $req->setMethod(HTTP_REQUEST_METHOD_PUT);

 $result = $req->addFile("test.txt", "C:/test.txt");
 if (PEAR::isError($result)) {
     echo $result->getMessage();
 } else {

     $response = $req->sendRequest(true);

     if (PEAR::isError($response)) {
         echo $response->getMessage();
     } else {
         echo $req->getResponseBody();
     }
 }
 print_r($req);
 ?>
 }}}

 In your agavi action do something like:

 {{{
         public function execute(AgaviParameterHolder $parameters)
         {
                 $file = $parameters->getFile('put_file');
                 // This will blow up as tmpfile() needs reworking
                 $file->move('C:\TMP\test.txt');
                 echo '<pre>';
                 print_r($_SERVER);
                 die(' ::::::::: ok');
                 return 'Success';
         }
 }}}

-- 
Ticket URL: <http://trac.agavi.org/ticket/393#comment:3>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5


_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets

Reply via email to