I am trying to pass multiple image files along with album id to insert.php, but only the file details are passing – but no album id. Grateful if someone can assist on this.
My code is below: It passes all file data but not album data to insert.php.
I am using uploadify v2.1.4
$(document).ready(function(){
//alert('I am Ready!');
$("#file_upload").uploadify({
'debug' : true,
'uploader': 'uploadify.swf',
'cancelImg': 'cancel.png',
'auto': false,
'multi' :true,
'method' : 'post',
'postData' : {},
'queueSizeLimit' : 10,
'onQueueFull' : function(event, queueSizeLimit){
alert(" You can upload " + queueSizeLimit + " files at once");
return false;
},
'onComplete': function(event, ID, fileObj, response, data) {
var album_id = $("#album_id").val();
$.post("insert.php", {
name: fileObj.name,
path: fileObj.filePath,
size: fileObj.size,
album_id:album_id},
function(info){
alert(info);
});
}
});
});
</script>
</head>
<body>
<form method="post" action="">
<input type="file" name="file_upload" id="file_upload" />
<select id="album_id" name="album_id">
<option value="1">First type</option>
<option value="2">Second type</option>
</select>
<a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
</form>
</body>
</html>
Try to get the value from the selected option like this:
Also, I think you have a problem with using album_id without quotes as property name in the JSON data. Try this: