Sorry i was completely missing the form element in the code, guess I’m going blind at just 20. What you can do to set the name is the following, first create an event handler for the name input like the below example…
$('[name="NameGuest"]').keyup(function() {
if (!$(this).val().length) {
alert('Please enter your name!');
} else {
uploadifySD.NameGuest = $(this).val();
$('#file_upload').uploadifySettings('scriptData', uploadifySD);
}
});
Essentially with the following event we can dynamically update the uploadify scriptData values in real time, the next thing we need to do is update the form and code a little as in my head we only want the form to upload the file(s) if a name is entered. See the example code below on how to achieve this…
<form id="form1" name="form1" method="post" action="">
<input name="NameGuest" type="text" id="NameGuest" size="50" />
<input id="file_upload" name="file_upload" type="file" />
<a href="#upload-files">Upload Files</a>
</form>
$('a[href*="upload-files"]').click(function(e) {
e.preventDefault();
if ($('[name="NameGuest"]').val().length) {
$('#file_upload').uploadifyUpload();
} else {
alert('Please enter your name!');
}
});
The final thing we need to do is update the uploadify code you already have so it uses a global var to dynamically set the NameGuest value.
var uploadifySD = {NameGuest: ''};
$('#file_upload').uploadify({
'uploader' : 'Upload/uploadify.swf',
'script' : 'Upload/uploadify.php',
'cancelImg' : 'Upload/cancel.png',
'folder' : 'NewGallery/photos',
'auto' : false,
'multi' : true,
'queueID' : 'Que',
'method' : 'POST',
'scriptData' : uploadifySD
});
Essentially by the end your javascript should look something like
$(function() {
var uploadifySD = {NameGuest: ''};
$('#file_upload').uploadify({
'uploader' : 'Upload/uploadify.swf',
'script' : 'Upload/uploadify.php',
'cancelImg' : 'Upload/cancel.png',
'folder' : 'NewGallery/photos',
'auto' : false,
'multi' : true,
'queueID' : 'Que',
'method' : 'POST',
'scriptData' : uploadifySD
});
$('[name="NameGuest"]').keyup(function() {
if (!$(this).val().length) {
alert('Please enter your name!');
} else {
uploadifySD.NameGuest = $(this).val();
$('#file_upload').uploadifySettings('scriptData', uploadifySD);
}
});
$('a[href*="upload-files"]').click(function(e) {
e.preventDefault();
if ($('[name="NameGuest"]').val().length) {
$('#file_upload').uploadifyUpload();
} else {
alert('Please enter your name!');
}
});
});