Welcome Guest, Not a member yet? Register   Sign In
Large file upload with SWFUpload jQuery Plugin
#1

[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" >&nbsp;</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 &raquo;</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]
&lt;style type="text/css" &gt;
    #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('&lt;?php echo base_url(); ?&gt;testifunc/cancel.png') no-repeat; cursor:pointer; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;input type="text" id="test"  /&gt;    
<div id="swfupload-control">
    &lt;input type="button" id="button" /&gt;
    <p id="queuestatus" ></p>
    <ol id="log"></ol>
</div>
http://test.com
#2

[eluser]rogierb[/eluser]
Is php.ini set up to allow for big uploads?
e.g. upload_max_filesize and post_max_size?
#3

[eluser]Zeeshan Rasool[/eluser]
Did you increase upload max file size for server? it can be changed in php.ini
#4

[eluser]farbar[/eluser]
Thanks
I changed max size in php.ini:
Code:
upload_max_filesize = 80M
post_max_size = 80M
And now codeigniter doesn't send any error.
But I got another error:

SWF DEBUG: Event: uploadError : Upload limit reached. No more files can be uploaded.

I know the error is related to SWFUpload and I must slove it.
#5

[eluser]sharpe[/eluser]
I'm getting this:
Code:
SWF DEBUG: Array
SWF DEBUG: (
SWF DEBUG:     [error] => <p>The filetype you are attempting to upload is not allowed.</p>
SWF DEBUG: )

This is the config
Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_height']  = '768';

But the swf returns this
Code:
[uploadfile] => Array
SWF DEBUG:         (
SWF DEBUG:             [name] => buton_nou_cs.gif
SWF DEBUG:            [type] => application/octet-stream
SWF DEBUG:             [tmp_name] => /tmp/phpv5bEW7
SWF DEBUG:             [error] => 0
SWF DEBUG:             [size] => 48148
SWF DEBUG:         )

It always return [type] => application/octet-stream.

How did this work for you?
#6

[eluser]Fabdrol[/eluser]
add 'application/octet-stream' to the mime types config file for image uploads ;-)
see: http://codeigniter.com/wiki/SWFUpload/




Theme © iAndrew 2016 - Forum software by © MyBB