[eluser]farbar[/eluser]
Using Codeigniter 1.7.2 and "
SWFUpload jQuery Plugin" , I can successfully upload small images to server.
When I upload a large file for example 50 mb , progressbar show uploading and SWFUpload show that upload have been completed but codeigniter generate "
You did not select a file to upload" error that means "uploadfile" variable is empty.
Have any one can help to solve this problem.
This is my controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ifuncupload extends Controller {
function Ifuncupload() {
parent::Controller();
$config['upload_path'] = getcwd().'\uploads';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '1000000000'; //large size
$config['max_width'] = '102400';
$config['max_height'] = '76800';
$this->load->library('upload', $config);
$this->load->helper(array('form', 'url'));
}
function index(){
$this->load->view('testupload/ifunc_form');
}
function do_upload() {
print_r($_POST);
if(!$this->upload->do_upload('uploadfile')){
$error = array('error' => $this->upload->display_errors());
print_r ($error);
}else{
print_r($this->input->post('test'));
}
}
}
?>
And my view:
Code:
[removed]
$(function(){
$('#swfupload-control').swfupload({
upload_url: "ifuncupload/do_upload",
file_post_name: 'uploadfile',
file_size_limit : 10000000000, //kb
file_types : "*.jpg;*.png;*.gif",
file_types_description : "Image files",
file_upload_limit : 1,
flash_url : "<?php echo base_url(); ?>testifunc/swfupload.swf",
button_image_url : '<?php echo base_url(); ?>testifunc/wdp_buttons_upload_114x29.png',
button_width : 114,
button_height : 29,
button_placeholder : $('#button')[0],
debug: true
})
.bind('fileQueued', function(event, file){
var listitem='<li id="'+file.id+'" >'+
'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
'<div class="progressbar" ><div class="progress" ></div></div>'+
'<p class="status" >Pending</p>'+
'<span class="cancel" > </span>'+
'</li>';
$('#log').append(listitem);
var swfu = $.swfupload.getInstance('#swfupload-control');
$('li#'+file.id+' .cancel').bind('click', function(){
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
para(swfu);
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message){
alert('Size of the file '+file.name+' is greater than limit');
})
.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
$('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('Uploading...');
$('#log li#'+file.id).find('span.progressvalue').text('0%');
$('#log li#'+file.id).find('span.cancel').hide();
})
.bind('uploadProgress', function(event, file, bytesLoaded){
var percentage=Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData){
alert(serverData);
var item=$('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
var pathtofile='<a href="uploads/'+file.name+'" target="_blank">view »</a>';
item.addClass('success').find('p.status').html('Done!!! | '+pathtofile);
})
.bind('uploadComplete', function(event, file){
$(this).swfupload('startUpload');
})
function para(s){
s.addPostParam('test', $('#test').val());
}
});
[removed]
<style type="text/css" >
#swfupload-control p{ margin:10px 5px; font-size:0.9em; }
#log{ margin:0; padding:0; width:500px;}
#log li{ list-style-position:inside; margin:2px; border:1px solid #ccc; padding:10px; font-size:12px;
font-family:Arial, Helvetica, sans-serif; color:#333; background:#fff; position:relative;}
#log li .progressbar{ border:1px solid #333; height:5px; background:#fff; }
#log li .progress{ background:#999; width:0%; height:5px; }
#log li p{ margin:0; line-height:18px; }
#log li.success{ border:1px solid #339933; background:#ccf9b9; }
#log li span.cancel{ position:absolute; top:5px; right:5px; width:20px; height:20px;
background:url('<?php echo base_url(); ?>testifunc/cancel.png') no-repeat; cursor:pointer; }
</style>
</head>
<body>
<input type="text" id="test" />
<div id="swfupload-control">
<input type="button" id="button" />
<p id="queuestatus" ></p>
<ol id="log"></ol>
</div>
http://test.com