Permalink
Browse files

File upload

  • Loading branch information...
1 parent 11d260b commit 8cdae7bbcc61642d2b5b4614254392928512d6ee @ghua committed Oct 21, 2012
Showing with 22 additions and 11 deletions.
  1. +2 −1 Controller/DirectController.php
  2. +0 −7 Router/Call.php
  3. +16 −1 Router/CallForm.php
  4. +4 −2 Router/Request.php
@@ -26,7 +26,7 @@ class DirectController extends Controller
public function __construct(ContainerInterface $container) {
$this->container = $container;
$this->response = new HttpFoundation\Response();
- $this->response->headers->set('Content-Type', 'application/json');
+ $this->response->headers->set('Content-Type', 'text/html');
}
/**
@@ -40,6 +40,7 @@ public function getApi()
$api = new Api($this->config);
$this->response->setContent(sprintf('Ext.ns("%1$s"); %1$s.REMOTING_API = %2$s;', $this->config['basic']['namespace'], $api));
+ $this->response->headers->set('Content-Type', 'text/javascript');
return $this->response;
}
View
@@ -53,13 +53,6 @@ class Call
* @var string
*/
protected $callType;
-
- /**
- * The ExtDirect upload reference.
- *
- * @var boolean
- */
- protected $upload;
protected $bundle;
View
@@ -8,6 +8,18 @@
class CallForm extends Call
{
+ /**
+ * The ExtDirect upload reference.
+ *
+ * @var boolean
+ */
+ protected $isUpload;
+
+ public function getIsUpload()
+ {
+ return $this->isUpload;
+ }
+
/**
* Initialize the call properties from a form call.
*
@@ -19,7 +31,7 @@ public function initialize($call)
'method' => 'extMethod',
'type' => 'extType',
'tid' => 'extTID',
- 'upload' => 'extUpload') as $key => $value)
+ 'isUpload' => 'extUpload') as $key => $value)
{
if(!isset($call[$value]))
throw new \Ext\DirectBundle\Exception\InvalidJsonException(sprintf('%s key does not exist', $value));
@@ -31,6 +43,9 @@ public function initialize($call)
foreach ($call as $key => $value) {
$this->data[$key] = $value;
}
+
+ if($this->getIsUpload())
+ $this->data = array_merge($this->data, $this->request->getFiles());
}
}
View
@@ -52,7 +52,7 @@ class Request
*
* @var array
*/
- protected $files;
+ protected $files = array();
/**
* Initialize the object.
@@ -67,7 +67,9 @@ public function __construct(HttpRequest $request)
array('null'),
$request->getContent());
$this->post = $request->request->all();
- $this->files = $request->files->all();
+
+ foreach($request->files->keys() as $key)
+ $this->files[$key] = $request->files->get($key, array());
}
/**

0 comments on commit 8cdae7b

Please sign in to comment.