php - Sending additional fields data with Uploadify -
i want send additional (form) fields data uploadify. purpose, using scriptdata. example, following code sends static values of name , location field correctly.
<script type="text/javascript"> $(document).ready(function() { $("#fileupload").fileupload({ 'uploader': 'uploadify/uploader.swf', 'cancelimg': 'uploadify/cancel.png', 'script': 'uploadify/upload.php', 'folder': 'files', 'multi': false, 'displaydata': 'speed', 'scriptdata': {'name':'johndoe', 'location':'australia'} }); }); </script>
however, have input fields name , location, therefore want send dynamic values. so, im sending values in scriptdata following
'scriptdata' : {'name' : $('#name').val(), 'location' : $('#location').val()}
and on upload.php, i'm trying
$name = $_get['name']; $location = $_get['location'];
but not of values. please me regarding this, how can send additional fields data. thanks.
because val()
's called when dom loaded, not when user types location , name in. should use 1 of events set new values. manual isn't clear it, think must onselectonce
event:
<script type="text/javascript"> $(document).ready(function() { $("#fileupload").fileupload({ 'uploader': 'uploadify/uploader.swf', 'cancelimg': 'uploadify/cancel.png', 'script': 'uploadify/upload.php', 'folder': 'files', 'multi': false, 'displaydata': 'speed', 'scriptdata': {'name':'', 'location':''}, 'onselectonce' : function(event,data) { $("#fileupload").uploadifysettings('scriptdata', {'name' : $('#name').val(), 'location' : $('#location').val()}); } }); }); </script>
Comments
Post a Comment