trong Uploadify Làm thế nào để vượt qua những giá trị người dùng nhập vào để uploadify.php đây là mã của tôi:làm thế nào để vượt qua giá trị tùy chỉnh trong Uploadify
$(function() {
$('#file_upload').uploadify({
'buttonText' : 'BROWSE...',
'method' : 'post',
'height' : 50,
'buttonCursor' : 'hand',
'fileSizeLimit' : '100KB',
'formData' : {
'title' :$('input:text[name:title]').val(),
'about' :$('input:text[name:about]').val() },
'auto' : false,
'swf' : 'uploadify.swf',
'checkExisting' : 'check-exists.php',
'uploader' : 'uploadify.php',
'onUploadSuccess' : function(file, data, response) {
$("#message").css("display","block");
$("#message").text("upload process completed successfully");
setTimeout(function() {
$('#message').fadeOut('fast');
}, 5000);
},
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
}
});
});
</script>
</head>
<?php include("includes/connection.php");?>
<body>
<div id="page">
<div id="header">
<h1>Photogallery</h1>
<?php include("includes/navigation.php"); ?>
</div><!--header-->
<div id="content">
<div id="left">
<div id="message">
</div>
<?php
?>
<table>
<tr>
<td>
<P>Title:</P>
</td>
<td>
<input type="text" value="" name="title" id="idtitle" />
</td>
</tr>
<tr>
<td>
<p>About:</p>
</td>
<td>
<p><input type="text" value="" name="about" /> </p>
</td>
</tr>
<tr>
<td>
Select Photos you want to Upload
</td>
<td>
<input type="file" name="file_upload" id="file_upload" />
</td>
</tr>
</table>
<a href="javascript:$('#file_upload').uploadify('cancel')">Cancel First File</a> | <a href="javascript:$('#file_upload').uploadify('cancel', '*')">Clear the Queue</a> | <a href="javascript:$('#file_upload').uploadify('upload', '*')">Upload the Files</a>
</div><!--left-->
Đây là tập tin uplodify.php tôi
<?php
require_once("includes/connection.php");
$targetFolder = '/workbench/sudeepc/photogallery/uploads' ;
$title=$_POST['title'];
// $title="testtitle";
$about=$_POST['about'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
$query="INSERT INTO `photo` (`id` , `path` , `uname` , `title` , `about` , `date`)
VALUES ('','${targetFile}','uname','${title}','${about}',now())";
/*
$query="INSERT INTO `photo` (`id` , `path` , `uname`)
VALUES ('','${targetFile}', '${title}');";
*/
mysql_query($query,$connection);
} else {
echo 'Invalid file type.';
}
}
?>
tôi muốn vượt qua tiêu đề cũng như về cho mỗi video tải lên và khi người dùng chọn nhiều hơn một người dùng hình ảnh có thể nhập tiêu đề và cho mỗi người. Làm thế nào tôi có thể giải quyết vấn đề này?
Hãy dừng viết mã mới với cổ 'mysql_ * 'chức năng. Chúng không còn được duy trì và cộng đồng đã bắt đầu [quá trình phản đối] (http://news.php.net/php.internals/53799). Thay vào đó bạn nên tìm hiểu về các câu lệnh đã chuẩn bị và sử dụng [PDO] (http://php.net/pdo) hoặc [MySQLi] (http://php.net/mysqli). Nếu bạn quan tâm để tìm hiểu, [đây là một hướng dẫn liên quan đến PDO khá tốt] (http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers). –
bây giờ mục nhập cơ sở dữ liệu là null. –
có cách nào để in truy vấn đó trong trình duyệt không? –