Welcome Guest, Not a member yet? Register   Sign In
Uploadify + CI / Experience?
#1

[eluser]trice22[/eluser]
Hello,

I'm currently trying to get the (flash) upload plugin uploadify for jQuery to play nicely with CI. The documentation is unfortunately quite "thin" and I'm having some serious problems debugging.

So I was wondering if anyone had already a chance to test the plugin and get it successfully working?

I'm currently not getting any error messages anymore, but the upload never starts either.

Cheers,
—trice
#2

[eluser]pistolPete[/eluser]
I didn't try it, but you should

- use Firebug to monitor HTTP requests and debug JS
- post your code here.

You could also have a look at swfupload.
#3

[eluser]trice22[/eluser]
Thanks for the swift answer.
Firebug doesn't really give me any good insights—it seems that the script never even starts the upload.
I'm currently wondering the most about how to structure the "script–path", since the documentation at "uploadify" doesn't really tell much about how it is used.

My JS code looks currently something like this:

Code:
$(document).ready(function() {
    $('form#guest-gallery input#image').fileUpload({
        'uploader':'<?php echo base_url(); ?>assets/swf/uploader.swf',
        'script':'/',
        'cancelImg':'<?php echo base_url(); ?>assets/img/layout/cancel.png',
        'folder':'/assets/js/plugins/_uploadify_debug/pics',
        'multi':true,
        'scriptAccess' : 'always',
        'onError' : function (a, b, c, d) {
         if (d.status == 404)
            alert('Could not find upload script. Use a path relative to: '+'<?php echo getcwd() ?>');
         else if (d.type === "HTTP")
            alert('error '+d.type+": "+d.status);
         else if (d.type ==="File Size")
            alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
         else
            alert('error '+d.type+": "+d.text);
        }
    });
});

The upload code in my controller works fine with a conventional upload.

—trice

EDIT: Turns out, I had accidently turned off the auto–upload feature. I'm still getting an error: Could not find upload script. Use a path relative to: [PATH TO MY APP] . No matter if I'm using a relative or absolute path or even just a "/".
#4

[eluser]Johan André[/eluser]
You should set the 'script'-option in the js to something... Preferably your upload script.

I can use the supplied upload.php & check.php but when I put them in a controller the plugin throws an error...
#5

[eluser]Unknown[/eluser]
I've managed to get it working with clean url's.

- My JS is included with a full base_url()

- The upload.php, uploader.swf, etc. are all in the same dir as the JS.

- The directory where the files should be uploaded is located at: <webserver_root>/images/subdir/uploads/

- The JS code looks like this:

Code:
$('#upload').fileUpload({
                        'uploader':'&lt;?php echo base_url(); ?&gt;js/jquery.uploadify/uploader.swf',
                        'script':'/js/jquery.uploadify/upload.php',
                        'cancelImg':'&lt;?php echo base_url(); ?&gt;js/jquery.uploadify/cancel.png',
                        'folder':'/images/subdir/uploads/',
                        'scriptAccess' : 'always',
                        'auto' : true,
                        'onError' : function (a, b, c, d) {
                         if (d.status == 404)
                            alert('Could not find upload script. Use a path relative to: '+'&lt;?php echo getcwd() ?&gt;');
                         else if (d.type === "HTTP")
                            alert('error '+d.type+": "+d.status);
                         else if (d.type ==="File Size")
                            alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
                         else
                            alert('error '+d.type+": "+d.text);
                        }
                    });

Hope this helps for you :)
#6

[eluser]Mousa[/eluser]
Hi guys, i know whats the problem. the problem is the file type which flash set it as “application/octet-stream”, so what this means? we should know the process of CI Upload Class to Upload a file. CI Upload Class validate file type, through extension of the file and its mime. if you take a look at CI/application/config/mimes.php, so you can see CI`s mime refrence to validate file types.

so, whats the solutions?

1- (simplest one) open CI/system/libraries/Upload.php and go to line 552, then replace this method :

Code:
function is_allowed_filetype()
{
return true;
}

or you can override this method with MY_Upload class. its your choice.

2- add “application/octet-stream” to the type of files you want to upload
open CI/application/config/mimes.php and add the “application/octet-stream” to files you want.

3- change the flash file to send the appropriate file type.

so , the problem is not CI, the Problem is not CI clean urls, or the limitations of get requests. i think this way is better than using external scripts and break ci process, so you can upload files with ci approach,validate users and process images.

good luck




Theme © iAndrew 2016 - Forum software by © MyBB