3

I am just trying to add a simple text field for a title and have it posted to uploadify.php, but it's not working.

Javascript:

$(function() {
    $("#file_upload").uploadify({
        'formData'      : {"title": $("#title").val()},
        'swf'           : '/uploadify/uploadify.swf',
        'uploader'      : '/uploadify/uploadify.php',
        'onUploadStart' : function(file) {
                $("#file_upload").uploadify("settings", "title");
        }
    });
});

HTML:

<input type="text" id="title" name="title" />
<input type="file" name="file_upload" id="file_upload" />

If I replace {"title": $("#title").val()} with {"title": "title"} it works fine but then it's not dynamic, it's just set to title. How can I get it passing the actual text field data? I've tried several things myself, but the Uploadify documentation is pretty thin.

1 Answer 1

8

The Uploadify documentation found here says otherwise, but this seems to be the correct way to utilize dynamic fields with Uploadify. In any case, it works.

$("#file_upload").uploadify({
        'swf'           : '/uploadify/uploadify.swf',
        'uploader'      : '/uploadify/uploadify.php',
        'onUploadStart' : function(file) {
                $("#file_upload").uploadify("settings", 'formData', {'title' : $("#title").val()});
        }
    });
});

Edit: It isn't required to have the formData declared in the first $("#file_upload").uploadify() so I removed it. Include it there as well if you want to use it to set default values.

Sign up to request clarification or add additional context in comments.

1 Comment

This works this if you want to do it on the "onUploadStart". I think the documentation in Uploadify uploadify.com/documentation/uploadify/formdata needs to be corrected? No?

Your Answer

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