Welcome Guest, Not a member yet? Register   Sign In
Codeigniter and Uploadify implementation
#1

[eluser]Unknown[/eluser]
1-YOUR VIEW FILE:


Code:
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
$(document).ready(function() {
    $("#uploadify").uploadify({
        'uploader'       : '<?=base_url()?>uploadify/scripts/uploadify.swf',
        'script'         : '<?=site_url('welcome/do_upload')?>',
        'cancelImg'      : '<?=base_url()?>uploadify/cancel.png',
        'folder'         : './uploads',
        'queueID'        : 'fileQueue',
        'fileDataName':'userfile',
        'auto'           : false,
        'multi'          : true,
        'fileExt': '*.jpg;*.jpeg;*.gif;*.png;',
        'fileDesc'      :'Please select Gif,JPG,PNG IMAGES',
        'queueSizeLimit' :'20',
        'buttonText': 'Uplaod Photo',
        onComplete: function(event, queueID, fileObj, reposnse, data) {
    // $('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
    alert(reposnse);
}
        
    });
});
[removed]

2.CONTROLLER

Code:
function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg';
        $config['max_size']    = '144400';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            echo $this->upload->display_errors();
            
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            print_r($data);
        }
    }
3. config/mimes.php
Code:
'bmp'    =>    array('image/bmp','application/octet-stream'),
                'gif'    =>    array('image/gif','application/octet-stream'),
                'jpeg'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
                'jpg'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
                'jpe'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
                'png'    =>    array('image/png',  'image/x-png','application/octet-stream'),



That's it.
Enjoy
#2

[eluser]gRoberts[/eluser]
Depending on the file types, I just used:

Code:
$_FILES['Filedata']['type'] = mime_content_type($_FILES['Filedata']['tmp_name']); // force the mime type

This then put the mime type back to what it should be and the upload library would work as normal.
#3

[eluser]zrowcrypt[/eluser]
Its a simple thing and I still cant get it working dont know why Sad ?

VIEW..snippet:

[removed][removed]
[removed][removed]
[removed][removed]

...
...

<div id="fileQueue"></div>


&lt;input id="fileInput" name="fileInput" type="file" /&gt;
[removed]// &lt;![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader' : '&lt;?php echo base_url();?&gt;js/uploadify/uploadify.swf',
'script' : 'uploadify/do_upload',
'cancelImg' : './img/uploadify/cancel.png',
'folder' : './js/uploadify/pics',
'queueID' : 'fileQueue',
'fileDataName' :'userfile',
'auto' : true,
'multi' : true,
'fileExt': '*.jpg;*.jpeg;*.gif;*.png;',
'fileDesc' :'Please select Gif,JPG,PNG IMAGES',
'queueSizeLimit' :'20',
'buttonText': 'Uplaod Photo',
onComplete: function(event, queueID, fileObj, reposnse, data) {
//$('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
alert(reposnse);
});
});
// ]]>[removed]


The view doesn't show me the swf stuff but just the plain html input box and button...which most probably means either my JQuery or Uploader is not getting loaded...but when i check the view source the path of both of these js and swf files are correct.

Any help will be deeply appreciated. I am stuck here badly Sad.
#4

[eluser]onsetrese[/eluser]
Hi,

I also followed this tutorial but i get http error, 302 I think. And havent found any work around.

Regards
Harold
#5

[eluser]tokanizar[/eluser]
Me either!

I think with default package from Uploadify, we cannot use with "pretty" URL like http://mysite.com/image/uploader

This is access log from my localhost Apache server:

Code:
127.0.0.1 - - [19/Jul/2011:14:04:41 +1200] "POST /image/uploadify HTTP/1.1" 500 540
127.0.0.1 - - [19/Jul/2011:14:05:01 +1200] "GET /image/uploadify HTTP/1.1" 200 63

As can be seen from the log, the link /image/uploadify is still accessible by direct access in browser but cannot use for Uploadify to post data.




Theme © iAndrew 2016 - Forum software by © MyBB