我正在尝试将一些信息插入数据库,我的第一页是这样的:
$(document).ready(function() {
//alert('I am ready to use uploadify!');
$("#file_upload").uploadify({
'uploader': 'uploadifyit/uploadify.swf',
'script': 'uploadifyit/uploadify.php',
'cancelImg': 'uploadifyit/cancel.png',
'folder': 'images',
'auto': false, // use for auto upload
'multi': true,
'queueSizeLimit': 4,
'onQueueFull': function(event, queueSizeLimit) {
alert("Please don't put anymore files in me! You can upload " + queueSizeLimit + " files at once");
return false;
},
'onComplete': function(event, ID, fileObj, response, data) {
// you can use here jQuery AJAX method to send info at server-side.
$.post("insert.php", { name: fileObj.name }, function(info) {
alert(info); // alert UPLOADED FILE NAME
});
}
});
});
</script>
</head>
<body>
<?php
$img_id=$_REQUEST['img_id'];
?>
<form id="form1" name="form1" action="">
<input type="file" name="file_upload" id="file_upload" /><br />
<input type="hidden" value="<? echo $img_id ;?>" name="image_id" />
<a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
</form>
而处理形式是:
if(isset($_POST)) {
//echo $_POST['name'];
$fileName = $_POST['name'];
$id = $_REQUEST['image_id'];
mysql_query("INSERT INTO tbl_images(img_file,img_gal_id) VALUES('$fileName','$id')");
$inserted_id = mysql_insert_id($dbc);
if($inserted_id > 0) { // if success
echo "uploaded file: " . $fileName;
}
}
我可以发布 $fileName 但不能发布 $id。