This forum is a community forum meant for users of the plugin to collaborate and help solve issues with implementation, etc. Unfortunately, as the creator of the plugin, I do not have much time to attend to every request here as this is only a side project and I must work a full-time job to provide for my family. This is how I keep the Flash version free and the HTML5 version low cost.
UploadiFive 1.1.1 has been released which includes a small fix for added support on touch devices including iOS 6 devices.
Details to script path
  • Hello,

    I just discovered uploadify—thanks for that!

    Since I'm trying to get uploadify to work with CodeIgniter (which currently) doesn't work, I was wondering, if someone could maybe provide me with some details on the server side script. I'm currently using a ready script for "regular" file uploads, which I'd like to use for uploadify as well.
    Does the script has to return anything (else but the "1" for OS X)? CodeIgniter uses pretty URLs and I'm a bit confused on how my script path has to look like in this case.

    Currently I'm not getting any error messages (anymore), but the upload never starts.
    Any help/advice/hint would be highly appreciated,
    trice
  • I don't know how codeigniter works, but by answering some of the questions I may be able to help.

    1. Are you checking for a session at the start of your upload page?
    2. using pretty URI do you need to pass a script path (for example) as index.php/tools/uploadify/uploader.php?

    You don't have to pass 1 back to the uploader. It can be any data but it must be some form of data, it can't be ' '. There is a bug in the flash player that won't trigger the onComplete function if nothing is passed back. All flash 8 & 9 uploaders have this issue.
  • Hello and thanks for your reply,

    Yes I'm checking for a session on this particular page—should I passing back the session ID?
    The problem with these pretty URLs and CodeIgniter is, that URLs like http://www.example.com/gallery/upload are not pointing to one particular script but using a MVC structure, pointing to a controller and a method inside this controller rather than one single (PHP) file. I can try to write my own routing functionality to solve this problem, in case it's required to point the script parameter to an actual file.

    Cheers,
    —trice
  • If you are using a full URL, and not a relative path, you need to clear the pagePath variable in the uploadify.js file.
  • I actually added a parameter for this to the settings in order to gain some more control over this parameter, but didn't succeed so far.
    Are you saying that—as long as there's an upload script in some form "on the other end"—the upload should work? My URL could for example look something like this:
    http://www.example.com/files/upload

    Cheers,
    —trice
  • At the moment Uploadify gets the base folder and adds it to the front of your upload script url. So take for instance if your calling file is stored inside a folder called "fileManagement" and your other settings are

    script: "upload.php"
    uploader: "uploadify.swf"
    etc....

    when flash calls uploadify.swf it actually sends filemanagement/uploadify.swf Ronnie implemented this way to keep all paths relative to the calling file. I have suggested to him that we make with a option it use relative or absolute paths. kpytlik suggestion of clearing pagePath in the uploadify.js file is correct if you are entering full URLs or mod_rewrite (pretty URLs).

    Adding pagePath to your settings in .fileUpload() wont succeed, as there is no code in the uploadify.js to pull your value and use it instead of the default. Until the relative/absolute option is enabled it's easier just to set pagePath to null in the uploadify.js
  • Sorry, my bad. What I had meant, is, that I have actually modified the the JS file in a way, that it can accept my value.
    I've added a setting parameter called "basePath" which takes "location.pathName" as default and can be set otherwise through a different value from outside.

    —trice
  • Could you post the full js file for this? I'm having trouble getting Uploadify to work with CI too.
  • Hi fokes,

    I'm a codeIgniter developer to and I'm trying to implement Uploadify too.
    While debugging I noticed, as mentioned in this thread earlier that Uploadify takes every option relative to the upload page. I changed the settings a bit so I could set my own pagePath, but my problems persist.

    Somehow Uploadify gives back an 302 http error (Page "found", strange error) and a error IO: Error #2038. What can be causing this? I used SWFUpload before, and remember it was needed to add some htaccess to the server for it to work (something about security in apache)

    Well, I'm kinda stuck in the ongoing battle between Uploadify and CodeIgniter.. 8-) What to do next?

    thanks to anyone who can help!
  • Bramme said:
    Could you post the full js file for this? I'm having trouble getting Uploadify to work with CI too.


    Oh, and Bramme, you need to change 2 lines in your JS file:


    // After: (line 62)
    settings = $.extend({
    // Add:
    pagePad: location.pathname,


    Line 82:

    // change this
    var pagePath = location.pathname;
    // Into this
    var pagePath = settings.pagePad;


    Lines 61 to 85 will look like this:

    $(this).each(function(){
    settings = $.extend({
    pagePad: location.pathname,
    uploader: 'uploader.swf',
    script: 'uploader.php',
    folder: '',
    height: 30,
    width: 110,
    cancelImg: 'cancel.png',
    wmode: 'opaque',
    scriptAccess: 'sameDomain',
    fileDataName: 'Filedata',
    displayData: 'percentage',
    onInit: function() {},
    onSelect: function() {},
    onCheck: function() {},
    onCancel: function() {},
    onError: function() {},
    onProgress: function() {},
    onComplete: function() {}
    }, options);
    var pagePath = settings.pagePad;
    pagePath = pagePath.split('/');
    pagePath.pop();
    pagePath = pagePath.join('/') + '/';
  • My understanding is if you are getting a 302 error it is a redirection issue. Check your mod-rewrite settings.
  • Well, I'm getting a few errors actually.
    I attached them, in order of appearence.
    Maybe you or anyone can help!

    thanks!
  • You have just shown your issue. Uploadify can not find your upload script. Do as it says, use a path relative to the directory stated and it should start working.
  • Yeah, I got that part ;-) but I'm a CodeIgniter developer so I have a full path only!
    Tried to mod the JS file, as I posted earlier, but that doesn't seem to work..
  • do you have flash?
  • Does anyone manage to fix CodeIgniter and Uploadify problem in the end.
    I use mod rewrite and friendly url
  • I got it working through the use of several work-arounds, none of which are perfect but they seem to do the trick. I'll explain the basic process I used and provide a link to an archive containing my work. There's too much to post here...

    I added the Uploadify folder, containing uploadify.php, to my root directory, and made sure that it was included in the .htaccess file so that CI would recognize it.

    In uploadify.php, I added some functions for altering/cleaning the filename, etc. Basically a copy/paste of some of the functions (set_filename(), prep_filename(), get_extension()) from CI's Upload.php library, as well as underscore() from the Inflector.php helper, with a few minor mods to make sure that they weren't trying to use CI-specific code.

    There's also an array_to_json() function that I had to include because my client's server has an earlier version of PHP5 that does not include the json_encode() or json_decode() functions. That was fun figuring out, let me tell you...

    After the move_uploaded_file() function in upload.php, I needed to build a special array of file values, convert them to json using the array_to_json() function mentioned above, and echo that json array to the browser. Of course, since all this is happening in Jquery, the browser doesn't display the code, but Jquery uses it to talk back to CI and write the file data, along with a few other tidbits such as user_id and such to the database.

    In my Controller file (in this case, dashboard.php) I have an upload() function where I generate my javascript and echo it to the view file's headers. I could add it right to the view file, but there are multiple user roles that access this Controller, and only one with upload permissions. Here's my function:

    function upload() {
    $client_id = $this->Sql->getClientUserClientId($user_id);
    $uploadify = <<<JS
    <script type=\"text/javascript\">
    $(document).ready(function() { // wait for document to load
    $('#claimfile').fileUpload({
    'uploader' : '/js/uploader.swf',
    'script' : '/uploadify/upload.php',
    'scriptData' : {'client_id':'
    JS;
    $uploadify.= $client_id;
    $uploadify.= <<<JS2
    '},

    'scriptAccess' : 'sameDomain',
    'multi' : true,
    'fileDataName' : 'claimfile',
    'cancelImg' : '/images/icon-delete.gif',
    'auto' : true,
    'folder' : '/files',
    'fileExt' : '*.txt;*.rtf;*.doc;*.docx;*.pdf;*.mp3;*.wav;*.aif;*.wp5;*.wpd;*.jpg;*.png;*.zip',
    'fileDesc' : 'Select files of type .txt, .rtf, .doc, .pdf, .mp3, .wav, .aif, or .zip',
    'sizeLimit' : '3072000',
    'simUploadLimit': '8',
    'onError' : function (a, b, c, d) {
    if (d.status == 404)
    alert('Could not find upload script. Use a path relative to: '+'<?= 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);
    },
    'onComplete' : function (event, queueID, fileObj, response, data) {
    $.post(\"/dashboard/uploadify\", { 'filearray' : response });
    },
    'onAllComplete': function(event, data) {
    alert(\"Uploading Complete!\\nTotal uploaded: \"+data.filesUploaded+\"\\nTotal errors: \"+data.errors+\"\\nClose this box to refresh the page and see your uploaded files.\");
    $.post(\"/dashboard/uploadify_notify\", { 'client_id':'
    JS2;
    $uploadify.= $client_id;
    $uploadify.= <<<JS3
    ','notify_type':'uploaded' });
    window.location.href=\"/dashboard\";
    }
    });

    $(\"tr:odd\").addClass(\"odd\");
    });
    </script>
    JS3;
    $x['scripts'][] = $uploadify;
    $this->load->view('uploads_v');
    }


    I also have two additional functions, uploadify() and uploadify_notify(). uploadify() gets that json array from the upload.php script above, and does the SQL insert of the file data into the database. uploadify_notify() send an email to the appropriate recipients notifying them that the file has been uploaded. Here are those functions, for what it's worth:


    function uploadify() {
    $file_array = array();
    $farray = $_POST['filearray']; // the json array from /uploadify/upload.php
    $farray = str_replace('{','',$farray); // get rid of curly brackets
    $farray = str_replace('}','',$farray);
    $farray = trim($farray); // get rid of any extra white space
    $fparts = explode(\", \",$farray); // turn it back into a PHP array
    foreach ($fparts as $fp) {
    $key = strtok($fp, \": \");
    $key = str_replace(\"'\",'',$key);
    $val = strtok(\": \");
    $val = str_replace(\"'\",'',$val);
    $file_array[$key] = $val;
    }
    $this->Sql->insertFile($file_array); // save it to the db
    }

    function uploadify_notify() {
    $client_id = $_POST['client_id']; // get the client ID from the Jquery script above
    $notify_type = $_POST['notify_type']; // there are various notification types - only relevant to my purposes but included for what it's worth
    $this->send_notification($client_id,$notify_type); // sends the notification thru CI's Email class in another function.
    }


    I'll upload my example code shortly.

    Again, much of this code is relevant only directly to the specific project I was working on, but hopefully the rest of you can use bits and pieces and whatever you can glean from it to make your installation work.

    Cheers,
    Bob
  • You would never feel unbearable heat and sweat inside, because the Air Jordans is designed to be the best wear for this season.The same as many other
    Air Jordan Shoes,the release of the Air Yeezy Shoes also arouse fierce arguments among sneaker fans.
  • I use uploadify with codeigniter on a regular basis,
    here is the method how i made it to work,

    1] keep the uploadify script in root folder of your project,
    eg: if www/MyProject is ur project's index, then keep ur uploadify scripts in MyProject folder.

    2] include the uploadify folder in the .htaccess file for permissions.

    3] first, just try to implement the uploadify using
    'script' : '<?php echo base_url(); ?> uploadify/uploadify.php',
    'folder' : '/MyProject/uploads',

    never use any other path for script... i kno it is not MVC but u have to use uploadify.php only for uploading the file.
    u can use specify another folder if u want.

    4] now, there is a callback function in uploadify..
    'onComplete' : function(event,fileObj,data,response)

    so, when the upload is complete, it triggers this function,
    "response" is a variable which stores whatever u have "echo"ed in "uploadify.php"

    5] the default uploadify.php script echo the file path after upload,
    echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);

    it gives me -> /MyProject/uploads/akhil.jpg

    6] now, use ajax in the function 'onComplete' to send this response to ur controller function

    'onComplete' : function(event,fileObj,data,response)
    {
    alert(response);
    $.ajax({
    url: "controller_url",
    type:"POST",
    data:"file_path="+response,
    success: function(html)
    {
    alert(html);
    },
    error: function(html)
    {
    alert(html);
    }
    });//ajax over
    },


    7] the path exact path for this file in ur controller will be
    $_SERVER['DOCUMENT_ROOT'].$this->input->post('file_path')

    8] so, as u have got the path for required uploaded file in ur controller,
    so u can now read,write,delete or do some experiments on this file.

    if it is an image or media, just display it on a webpage.. :)





  • Has anybody tried to turn on CodeIgniter query strings? what if the upload.php file might be replaced by index.php?c=controller&m=method ??? index.php and uploadify.swf would be in the same directory...
  • I've tried to set up uploadify to work with CI, but using is included upload.php scripts. It doesn't matter what I do, it always triggers a request to /false once the uploadify.swf file gets loaded.

    What am I doing wrong here?