其實我存儲在數據庫中的三個值,它成功地保存日期,路徑,但不是存儲庫ID,這裏是我的代碼,我使用錯誤:沒有存儲ID數據庫
<?php ob_start();
session_start();
include("include/conf.php");
$getid=$_GET['id_cms'];
$galleryid=$_GET['gallery'];
$date=date("F j, Y, g:i a");
$targetFolder = '/uploads'; // Relative to the root
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$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);
move_uploaded_file($tempFile,"gallery/".$_FILES['Filedata']['name']);
$path=$_FILES['Filedata']['name'];
mysql_query("Insert into gallery (gall_date,albumid,gallery_path) VALUES('$date','$galleryid','$path')",$cn) or die("Insert Query Error");
}} ?>
我有已經花了兩天時間,但都在徒勞。
請問任何機構都可以解決我的問題。在此先感謝
編輯:不正確的建議。 – Will
'ID' fiield是否有默認的自動增量? – k102
使用mysqli_ *功能.. –