如果您正在使用的會話,請檢查您是否已經開始會話即在session_start()
如果你想從uploadify函數傳遞POST_ID到PHP文件,您可以使用下面的函數中提到的scriptData。
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//uploadify function
$("#file_upload").uploadify({
'uploader': 'uploadify.swf',
'script': 'uploadify.php',
'cancelImg': 'cancel.png',
'folder': 'photos', //folder where images to be uploaded
'auto': false, // use for auto upload
'multi': true,
'queueSizeLimit': 6,
'buttonImg': 'images/upload.png',
'width': '106',
'height': '33',
'wmode': 'transparent',
'method': 'POST',
'scriptData': {'myid':post_id}, //you can post the id here
'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) {
$("#uploadfiles").append(response+",");
},
'onAllComplete': function(response, data) {
showAll();
}
});
</script>
uploadify.php
if (!empty($_FILES)) {
$post_id = $_POST['myid'];
include_once "config.php";
//use this when uploading images into a folder
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$fna = $_FILES['Filedata']['name'];
$targetFile = str_replace('//','/',$targetPath) . $fna;
move_uploaded_file($tempFile,$targetFile);
//folder upload end
$name2 = mysql_real_escape_string($_FILES['Filedata']['name']);
$mime2 = mysql_real_escape_string($_FILES['Filedata']['type']);
$data2 = mysql_real_escape_string(file_get_contents($_FILES['Filedata']['tmp_name']));
$size2 = intval($_FILES['Filedata']['size']);
$db->query("INSERT INTO tbl_files SET post_id='$post_id', filename='$name2', file_data='$data2', mime_type_id='$mime2'");
}
$ POST_ID是主鍵正確的,所以插入單獨領域的其餘部分沒有$ POST_ID – 2012-03-15 10:32:56
沒有,帖子ID是外鍵。它是文件附加的帖子的ID。就像電子郵件和附件之間的關係一樣。 – 2012-03-15 10:41:53
什麼是$ post_id?你是否通過uploadify函數調用了post_id – nithi 2012-03-15 10:43:35