I'm using uploadify on a page that allows a user to upload images as well as a category field in which to send those images. Now, I see that uploadify provides a "scriptData" method that allows me to send over key value pairs to the uploadify.php script. But the problem is that the scriptData method grabs its values upon page load(uploadify initialization). Thus when a user is on the page changing values, scriptData still only has the default values that were there on page load.
Is there anyway around this?
Thanks a million!
Possible solution: I was reading the manual further and discovered that you can change the settings through a function call. Possibly on the right track?
$('#fileInput').uploadifySettings('scriptData', getKeyValuePairs()).uploadifyUpload();
working on it now..
you would need to fetch the current state of the user's input via one of uploadify's callback hoock: onOpen or onSelect . See their documentation for the right one. I guess onOpen is more reliable as it will check the current state of user input everytime an upload is started. Still, you might need to disable other user inputs while an upload is ongoing, or still require the user to submit the form, otherwise any user input done after the last upload has started will be lost.
Anyway, I found this on their forum, which i would put on a onOpen
callback:
$('#fileInput2').uploadifySettings(
'scriptData',
{'ext':$('#dirTimeStamp').val(), 'ext2':$('#txtEmail').val()}
);
A final implementation would be (using the demo code) :
<input id="fileInput" name="fileInput" type="file" />
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader' : 'uploadify.swf',
'script' : 'uploadify.php',
'cancelImg' : 'cancel.png',
'auto' : true,
'folder' : '/uploads',
'onOpen' : function(){
$('#fileInput').uploadifySettings(
'scriptData',
{'ext':$('#dirTimeStamp').val(), 'ext2':$('#txtEmail').val()}
);
}
});
});
// ]]></script>