Hoping you can help - I'm new to CakePHP and SWFUpload.
I am trying to implement SWFUpload in my project and I have got as far
as initializing the button
and fixed a 203 error I was getting thanks to Adam Royal's fix.
The problem is that it does not appear to be calling my simple upload
function.
Here is the init file:
/webroot/js/js.php
<?php
ob_start('ob_gzhandler');
echo join('',file('jquery/jquery-1.2.6.min.js'));
echo join('',file('common.js'));
ob_end_flush();
?>
Here is the common.js file which initializes SWFUpload
/webroot/js/swfupload/common.js
// init swfupload var
var swfu;
// on dom ready
$(document).ready(function(){
var settings = {
// url of flash uploader
flash_url : "/js/swfupload/swfupload.swf",
// controller and action to deal with uploads
upload_url: "/client_albums/upload/",
// insert session id
post_params: {"PHPSESSID" : session_id},
// set file limit
file_size_limit : "1 MB",
// restrict to jpegs only
file_types : "*.jpg;*.jpeg",
// what to display in file dialog box
file_types_description : "JPEG Files",
// upload limit
file_upload_limit : 5,
// queue limit
file_queue_limit : 5,
// ids of custom divs
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
// set debug to false
debug: true,
// setup the button
button_width: "110",
button_height: "30",
// uses a sprite to handle normal/hover/active clicks
button_image_url : "/img/button_sprite.png",
// id of button in view
button_placeholder_id: "spanButtonPlaceHolder",
// insert into placeholder
button_text: '<span class="theFont">Upload Files</span>',
// style the font
button_text_style: ".theFont { font-size: 16px; }",
// set padding
button_text_left_padding: 12,
button_text_top_padding: 3,
// The event handler functions are defined in handlers.js
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
queue_complete_handler : queueComplete // Queue plugin event
};
// init swf object
swfu = new SWFUpload(settings);
// select files
$('.selectFiles').click(function(){
// depreciated not compatable with flash 10
//swfu.selectFiles();
});
// cancel queue
$('.cancelQueue').click(function(){
swfu.cancelQueue();
});
});
And here is the upload function in client_albums controller
/**
* Deals with file upload
*/
function upload() {
//echo "here";
//exit();
// upload file to tmp dir
echo move_uploaded_file($_FILES['Filedata']
['tmp_name'],WWW_ROOT.DS.'tmp'.DS.$_FILES['Filedata']['name']);
exit;
}
My tmp dir is writable and I have included the beforeFilter function
in client_albums controller as follows:
function beforeFilter() {
if ($this->action == 'upload') {
$this->Session->id($this->params['pass'][0]);
$this->Session->start();
//debug($this->Session->read());
}
parent::beforeFilter();
}
Any ideas why it wouldn't be calling the simple upload function?
Many thanks :)
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment