Search code examples
phpjqueryuploadify

How can I implement a choose folder option in Uploadify?


Uploadify works great, and I love it. However, I just can't figure out how to make a dropdown list to select what upload folder to choose. I want my user to be able to select a folder to upload the file to. Anyone know a good way to do this? Preferably simple.


Solution

  • slight mistake ....

    <script type="text/javascript">
      $(document).ready(function() {
      $('#file_upload').uploadify({
        'uploader'  : '/uploadify/uploadify.swf',
        'script'    : '/uploadify/uploadify.php',
        'cancelImg' : '/uploadify/cancel.png',
        'folder'    : $("#folder").val(),
        'auto'      : true
      });
    }); // should not be here - goes above </script>
    
      $("#folder").change(function() {
        $('#file_upload').uploadifySettings('folder',$("#folder").val());
      });
    </script>
    

    my code (ignore locations of script / also I set folder to first option of #folder which happens to be dubstep on my dropdown)

    js head section

    <script type="text/javascript">
    $(document).ready(function() {
        $('#file_upload').uploadify({
            'uploader'          : 'upload/uploadify.swf',
            'script'            : 'upload/uploadify.php',
            'cancelImg'         : 'upload/cancel.png',
            'folder'            : 'upload/dropbox/dubmin',
            'fileExt'           : '*.mp3',
            'fileDesc'          : '.mp3 files only',
            'multi'             : true,
            'queueSizeLimit'    : 4,
            'queueID'           : 'queue',
            'sizeLimit'         : 52428800,
            'wmode'         : 'transparent'
            });
    
        $("#folder").change(function () {
            var path = "upload/dropbox/" + $(this).val();
            $('#file_upload').uploadifySettings('folder', path);
        });
        /* begin test to see if js switching to correct folder (remove or comment out section when done) */
        $('#test').click(function(){
            var folderz = $('#file_upload').uploadifySettings('folder');
            alert("folder is set to: "+folderz);
        });
        /* begin test to see if js switching to correct folder */
    });
    </script>
    

    html code

    <select id="folder" name="folder">
        <option value="dubtem">Dubstep</option>
        <option value="liqmin">Liquid</option>
        <option value="drknro">Neuro</option>
        <option value="other">Other</option>
    </select>
    <button type="button" id="test">Which Folder?</button>
    </p>
    <input id="file_upload" name="file_upload" type="file" />
    <div id="queue"></div>
    <a href="javascript:$('#file_upload').uploadifyUpload();"><img src="submit.png" id="submit_img"></a>
    

    comment out or erase test section from either html or js when done with it.