0

How can I update the "storage" var set in uploadify? I have this function set_path that updates the var combined to other values that is launched when some content is selected

$(document).ready(function () {
    $('#uploader').uploadify({
        'uploader': '/admin/includes/uploadify/uploadify.swf',
        'script': '/admin/includes/uploadify/uploadify_storage.php',
        'scriptData': {
            'sessionId': sessionId
        },
        'cancelImg': '/admin/includes/uploadify/cancel.png',
        'buttonImg': '/site_images/button.png',
        'folder': storage,
        'auto': false,
        'multi': true,
        'fileExt': '*.jpg',
        'simUploadLimit': 2,
        'wmode': 'transparent',
        'onComplete': function (event, ID, fileObj, name, response, data) {
            alert(storage);
        }
    });
    $("#start").click(function () {
        $("#uploader").uploadifyUpload();
    });
})
var absolute_path = "/admin/storage/files/";
var path = "";
var storage = absolute_path + path;

function set_path(new_path) {
    storage = absolute_path + new_path;
    show_path(new_path);
}

if set_path is launched the new storage var is updated infact the alert in "onComplete" shows the right content, the problem is that 'folder': storage contains the original "storage", and is not getting updated when setting a new path. Why?

2 Answers 2

1

Because the storage variable was only used to pass the value to uploadify settings array upon instantiating, it doesn't "live" there.

What you want to do is alter the 'folder' setting for the uploadify object.

According to Uploadify documentation, your set_path function should look like this:

function set_path(new_path) {
    $('#uploader').uploadifySettings ('folder', absolute_path + new_path);
    show_path(new_path);
}
Sign up to request clarification or add additional context in comments.

Comments

1

Since you fed the original object to the folder property, you need to re-set the value of the key.

In onComplete, grab a reference to the object you fed, or create a setter method and set its folder property to the new storage.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.