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.
fileUploadSettings problem
  • Hi

    At the beginning sorry for my poor English.
    I've got a little problem with fileUploadSettings function.

    In head section I've got something like that


    <script type=\"text/javascript\">
    $(document).ready(function() {

    $(\"#fileUpload2\").fileUpload({
    'uploader': 'public/js/uploader.swf',
    'cancelImg': 'public/img/cancel.png',
    'folder': '../public/images/',
    'buttonText': 'Wybierz pliki',
    //'checkScript': '_scripts/php/check.php',
    'script': 'upload.php',
    //'scriptData': {'id':'100'},
    'multi': true,
    'simUploadLimit': 5,

    });

    });
    </script>


    and it works, but I can't change the settings. I need to send additionally an "id" parameter. In another file I've got the input file


    <p>
    <input name=\"fileUpload2\" id=\"fileUpload2\" type=\"file\" />
    <script type=\"text/javascript\">
    $(\"#fileUpload2\").fileUploadSettings('scriptData','&amp;id='+100);
    </script>
    <a href=\"javascript:$('#fileUpload2').fileUploadStart();\">Start Upload</a> | <a href=\"javascript:$('#fileUpload2').fileUploadClearQueue()\">Clear Queue</a></p>


    but it doesn't work. Firebug in firefox shows this error message: document.getElementById($(this).attr("id") + "Uploader") is null

    Other settings like

    $(\"#fileUpload2\").fileUploadSettings(\"folder\",\"uploads\");

    doesn't work too.

    Placing that in a head section gives that error message in firebub: document.getElementById($(this).attr("id") + "Uploader").updateSettings is not a function


    <script type=\"text/javascript\">
    $(document).ready(function() {

    $(\"#fileUpload2\").fileUpload({
    'uploader': 'public/js/uploader.swf',
    'cancelImg': 'public/img/cancel.png',
    'folder': '../public/images/',
    'buttonText': 'Wybierz pliki',
    //'checkScript': '_scripts/php/check.php',
    'script': 'upload.php',
    //'scriptData': {'id':'100'},
    'multi': true,
    'simUploadLimit': 5,
    'fileDesc': 'Pliki graficzne *.jpg;*.jpeg;*.gif;*.png',
    'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
    //'sizeLimit': 100,

    });

    $(\"#fileUpload2\").fileUploadSettings(\"folder\",\"uploads\");

    });
    </script>

    Does anybody know where is the problem ?
  • You can't call the fileUploadSettings in that fashion. Please download the sample files in the download section. There are comments with the script files that explain what is happening and how you need to implement it.

    Essentially, fileUploadSettings needs to be bound to an event or used inside another function.
  • TravisN. said:
    You can't call the fileUploadSettings in that fashion. Please download the sample files in the download section. There are comments with the script files that explain what is happening and how you need to implement it..


    I read comments and the pdf manual bu there is no samples. There are only explaination what to put as arguments. I tried to put it to onclick event but it doesn't work

     <a href=\"javascript:$('#fileUpload2').fileUploadStart();\" onclick=\"$(\"#fileUpload2\").fileUploadSettings('scriptData','&amp;id='+100);\">Start Upload</a>
  • If you want to use it as


    you have a syntaxt error:

    <a href=\"javascript:$('#fileUpload2').fileUploadStart();\" onclick=\"javascript:$('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+100);\">Start Upload</a>
    note addition of javascript and single quotes inside double quotes #fileUpload2

    But if id is fixed and/or known when the page opens you should use

    scriptData: {'id' : 100},


    If it changes when entered into a field you need to bind it to change

    $('#idField').bind('change', function(){
    $('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+$(this).val());
    });


    If id is calculated when the page opens add the fileUploadSettings call to that function.

    Do not call fileUploadSettings directly in the .ready(). You are performing an asynchronous call, which means you are asking to set an option before it has finished initializing .fileUpload().
  • [quote="TravisN."]
    If it changes when entered into a field you need to bind it to change

    $('#idField').bind('change', function(){
    $('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+$(this).val());
    });

    /quote]

    I don't know the id when the main page loads. It is dynamically generating via php in body. So should I put an input hidden with my id ?

    <input type=\"hidden\" id=\"nr\" name=\"nr\" value=\"100\">
    <script type=\"text/javascript\">
    $('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+$(this).val());
    </script>
    <a href=\"javascript:$('#fileUpload2').fileUploadStart();\">Start Upload</a> | <a href=\"javascript:$('#fileUpload2').fileUploadClearQueue()\">Clear Queue</a></p>
    <p>&amp;nbsp;</p>
  • First, I am assuming when you are saying "id" you are referring to a variable, not the id of a HTML element.

    If it is generated within the page itself then call scriptData like
    [code=php]scriptData: {'id' : '<?php echo $yourVariable ?>'},[/code]

    If it is passed to the page via parameters you can use $_GET, $_POST or $_REQUEST
    [code=php]scriptData: {'id' : '<?php echo $_REQUEST</span>['yourPassedVariable'] ?>'},[/code]

    Make sure you encapsulate the php statements in quotes.
  • TravisN. said:
    First, I am assuming when you are saying "id" you are referring to a variable, not the id of a HTML element.

    If it is generated within the page itself then call scriptData like
    [code=php]scriptData: {'id' : '<?php echo $yourVariable ?>'},[/code]

    If it is passed to the page via parameters you can use $_GET, $_POST or $_REQUEST
    [code=php]scriptData: {'id' : '<?php echo $_REQUEST</span>['yourPassedVariable'] ?>'},[/code]

    Make sure you encapsulate the php statements in quotes.


    Ok it works, but my code is in many templates (I use smarty) and I don't want to put it i head section. I would prefer to put it in an appropriate body template.
  • The call to .fileUpload doesn't have to be in the head. You can move the whole function to the body. just enclose it in the usual tags. Does that answer what your trying to achieve?
  • TravisN. said:
    The call to .fileUpload doesn't have to be in the head. You can move the whole function to the body. just enclose it in the usual tags. Does that answer what your trying to achieve?


    I would like to put whole function in the head but without


    scriptData: {'id' : 100},


    I would like to change by fileUploadSettings in appropriate body template.
  • can you not use?

    <a href=\"javascript:$('#fileUpload2').fileUploadStart();\" onclick=\"javascript:$('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+'<?php echo $yourVariable ?>');\">Start Upload</a>

    or

    I haven't tried this, but what about adding this to your body template

    <a href=\"javascript:$('#fileUpload2').fileUploadStart();\">Start Upload</a> | <a href=\"javascript:$('#fileUpload2').fileUploadClearQueue()\">Clear Queue</a></p>
    <script type=\"text/javascript\">
    $('#fileUpload2').ready(function() {
           $('#fileUpload2').fileUploadSettings('scriptData','&amp;id='+'<?php echo $yourVariable ?>');
    });
    </script>

    In theory because your .fileUpload has been initiated in one file, when your body template finishes loading it should trigger the function when it finishes loading.
  • Hi,

    I'm happy to use this fantastic plugin but...
    I'm facing the same problem...
    i've followed your instructions...
    but in FF the only solution that i've found is this:


    fileUploadSettings:function(settingName, settingValue) {
    $(this).each(function() {
    var appoId=$(this).attr('id') + 'Uploader';
    setTimeout(\"document.getElementById('\"+appoId+\"').updateSettings('\"+settingName+\"','\"+settingValue+\"');\",1000);
    });
    },


    :shock:
  • This is the new way of changing settings:

    $('#uploadify').uploadifySettings('scriptData',{'language' : 'English'});

    Where #uploadify is the id of the input file.

    Hope this helps.

    Lee.
  • hi
    sorry for my english

    i need to change "folder" when i receive ajax-answer from server. i wrote:

    $(document).ready(function() {
    $(\"#fileUpload\").fileUpload({
    ...............
    'folder': 'upload',
    ...............
    });


    $('#add-gallery').click(function() {
    $.getJSON('/ajax/ajax.php', {action: 'new_gal', name: name}, function(data) {
    var folder = 'upload/gallery'+data.id;
    alert(folder);
    $('#fileUpload').fileUploadSettings('folder', folder);
    }
    });
    });
    });

    it works fine, but when i comment "//alert(folder);" firebug says - document.getElementById(a(this).attr("id") + "Uploader").updateSettings is not a function.

    What i need to do?
  • You done certain good points there. I did a search on the subject and found nearly all persons will agree with your blog. cheap home elevators