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.
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
Reset to default 8The 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.