Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Submit in folder
  • Dear users,

    Ive got the following HTML code:
          <form name=\"upload\" />
    <li> Directorie:
    <select name=\"dir\" id=\"selectList\">
    <option value=\"introductie\" id=\"state\">introductie</option>
    <option value=\"offertes\" id=\"state\">offertes</option>
    </select></li>>
    <li> <input type=\"file\" name=\"fileInput\" id=\"fileInput\" /> </li>
    <li> <a href=\"javascript:$('#fileInput').fileUploadStart();\">Upload Files</a> </li>
    <script type=\"text/javascript\">
    $(document).ready(function() {
    /*'folder' : 'documenten/' + jQuery ('select :selected').val() + '/' , */
    $('#fileInput').fileUpload ({
    'uploader' : '_phpincludes/template/swf/uploader.swf',
    'script' : '_phpincludes/lib/upload.php',
    'cancelImg' : '_phpincludes/template/img/cancel.png',
    'auto' : false,
    'multi' : true,
    'buttonText': 'Select bestanden',
    'folder' : 'documenten/' + jQuery ('select :selected').val() + '/',

    '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(a, b, c, d, e){
    if (d !== '1')
    alert('Bestanden zijn geupload in de map ' + jQuery ('select :selected').val() + '. U word nu doorgestuurd naar de index.');
    window.location = mainAdres;
    }
    });

    });
    </script>
    </form>


    But somehow the code only places the uploads in the introductie folder?
  • @xeon

    Try this...

    'folder'    : 'documenten/' + jQuery('#selectList option:selected').val() + '/',


    Haven't tried it but this syntax seems more inline with the jQuery doc example --> http://docs.jquery.com/Selectors/selected

    If it doesn't work, try loading the selected option into a var first...


    var sOptSelected = jQuery('#selectList option:selected').val();
    ...
    'folder' : 'documenten/' + sOptSelected + '/',


    HTH,
    A. Soong
  • Thank you for trying to find a solution. But unfortunately it didn't work.

    If i put the folder like
    folder: 'documenten/offertes/' 

    it simply works, but if i use
    'documenten/' + sOptSelected + '/',

    it bugs?
  • You need to bind your selectList to a 'change' event and use fileUploadSettings to update the folder. Your current code only sets the folder on the initialization of .fileUpload(). If nothing is selected when .fileUpload() is initialised it sets it with a null value.

    ie
    $('#selectList').change(function () {
    $('#fileInput').fileUploadSettings('folder', $(this option:selected).val());
    });


    also make sure you set the default selected list option. Although when your code runs it looks like the first option is selected, it is in fact not. you must set it to be selected. This is so when fileUpload() inits it can set the folder at least with the default.
    <option value=\"introductie\" id=\"state\" selected>introductie</option>
  • Thank you for your time TravisN. It is working correctly now.
  • by xeon
    You can show all You working code please
    I a little bit not to have understood that )
  • can you please post the final code?
    i try the same but i cannot get it working...

    thanks for your help!!!!

    greetings from Holland!