I am using codeigniter and uploadify. I am not using the built in uploadify.php, instead I am using my own function in my controller which I feel more suit with my application workflow. I have install uploadify and test it with it's built in .php file. it works good. But when I tried to use my own script, It couldn't upload the file. The error said :
A PHP Error was encountered
Severity: Warning
Message: Illegal offset type in isset or empty
Filename: libraries/Upload.php
Line Number: 147
You did not select a file to upload.
what is it mean? I am sure I've selected the file... for the clarity of my question, here's my code : The View:
<?php echo form_open_multipart('profile/do_upload_song');?>
<input id="uploadifyit" type="file" name="filedata" />
<a href="javascript:$('#uploadifyit').uploadifyUpload();">Upload Files</a>
<?php echo form_close(); ?>
The .JS:
$("#uploadifyit").uploadify({
'uploader' : 'js/jquery/jquery-plugins/uploadify/uploadify.swf',
'script' : 'profile/do_upload_song',
'cancelImg' : 'js/jquery/jquery-plugins/uploadify/cancel.png',
'folder' : 'media',
'scriptAccess' : 'always',
'displayData' : 'speed',
'auto' : false,
'multi' : true,
'fileDataName' : 'Filedata',
'fileExt' : '*.mp3',
'method' : 'post',
'removeCompleted' : false,
'onComplete': function(event, queueID, fileObj, reposnse, data) {
$('#fileinfotarget').append('<p>'+reposnse+'</p>');
}
});
The Controller:
function do_upload_song()
{
$config['upload_path'] = './media/';
$config['allowed_types'] = 'mp3';
$config['max_size'] = '144400';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($_FILES['Filedata']))
{
echo $this->upload->display_errors();
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
}
What's wrong with my code? Any advice guys? Thanks