I recently added jQuery file upload (https://github.com/blueimp/jQuery-File-Upload) to my custom-made CMS system. Uploading images works fine, but loading the uploaded images doesn't. In fact: the JSON string appears on top of my file:
{"files":[{"name":"foto1.jpg","size":221882,"url":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\foto1.jpg","thumbUrl":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\thumb\/foto1.jpg","deleteUrl":"http:\/\/cake.optiekcardoen.be\/app\/webroot\/index.php?file=foto1.jpg","deleteType":"DELETE"},{"name":"foto2.jpg","size":184839,"url":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\foto2.jpg","thumbUrl":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\thumb\/foto2.jpg","deleteUrl":"http:\/\/cake.optiekcardoen.be\/app\/webroot\/index.php?file=foto2.jpg","deleteType":"DELETE"},{"name":"foto3 (1).jpg","size":171300,"url":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\foto3%20%281%29.jpg","thumbUrl":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\thumb\/foto3%20%281%29.jpg","deleteUrl":"http:\/\/cake.optiekcardoen.be\/app\/webroot\/index.php?file=foto3%20%281%29.jpg","deleteType":"DELETE"},{"name":"foto3.jpg","size":171300,"url":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\foto3.jpg","thumbUrl":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\thumb\/foto3.jpg","deleteUrl":"http:\/\/cake.optiekcardoen.be\/app\/webroot\/index.php?file=foto3.jpg","deleteType":"DELETE"},{"name":"foto4.jpg","size":222763,"url":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\foto4.jpg","thumbUrl":"D:\\Websites\\Optiek Cardoen\\05 - Cake\\app\\webroot\\img\\outlets\\6\\thumb\/foto4.jpg","deleteUrl":"http:\/\/cake.optiekcardoen.be\/app\/webroot\/index.php?file=foto4.jpg","deleteType":"DELETE"}]}
How can I solve this so the JSON string doesn't appear like that anymore?
Here's the controller code in OutletPhotosController.php:
public function add()
{
App::import('Vendor', 'CoasterCms.UploadHandler', array('file' => 'jQueryFileUpload' . DS . 'UploadHandler.php'));
$options = array(
'upload_dir' => WWW_ROOT . 'img' . DS . 'outlets' . DS . $this->request->params['named']['outlet_id'] . DS,
'upload_url' => WWW_ROOT . 'img' . DS . 'outlets' . DS . $this->request->params['named']['outlet_id'] . DS,
'accept_file_types' => '/\.(gif|jpe?g|png)$/i',
'image_versions' => array(
'thumb' => array(
'max_width' => 20,
'max_height' => 20,
'crop' => true
)
)
);
$upload_handler = new CustomUploadHandler($options);
}
And here's my very simple script in main.js:
<script>
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
});
});
</script>
Thanks for helping ;)
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment