i use uploadify for my upload process. The problem is that after each upload lithium tries to render the view of the controller. In my case uploadify.html.php. How can i disable this behaviour and just return a 200 OK.
My controller code:
class UploadController extends \app\controllers\AppController {
public function index() {}
public function uploadify() {
Logger::write('info', 'start upload');
if (!empty($this->request->data)) {
$fileData = $this->request->data['Filedata'];
$error = $fileData['error'];
if($error == UPLOAD_ERR_OK) {
// everything ok
$tempFile = $fileData['tmp_name'];
$targetPath = $this->request->env('DOCUMENT_ROOT') . $fileData['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $fileData['name'];
move_uploaded_file($tempFile, $targetFile);
Logger::write('info', 'upload file successfull to ' . $targetFile);
} else if($error == UPLOAD_ERR_INI_SIZE || $error == UPLOAD_ERR_FORM_SIZE) {
// file size to large
Logger::write('error', 'file to large ' . $fileData['Filename']);
} else if($error == UPLOAD_ERR_PARTIAL) {
// only partial uplopad
Logger::write('error', 'uploaded partial ' . $fileData['Filename']);
} else if($error == UPLOAD_ERR_NO_FILE) {
// no file uploaded
Logger::write('error', 'couldn\'t upload ' . $fileData['Filename']);
} else {
Logger::write('error', 'Unknown error code ' . $error);
}
} else {
Logger::write('error', 'no form data');
}
}
}
To only renders the headers of the response, not the body, set
$this->render(array('head' => true))
Same with redirect()
Docs: http://li3.me/docs/lithium/action/Controller::render
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With