您好,我正在使用图像浏览器,其中有一个提交按钮以向数据库添加新行。不幸的是,isset 功能不起作用。当我删除这个 if 语句时它工作正常,但是当使用 if(isset($_POST['addImg'])) 时没有任何反应。
图像浏览器具有以下形式:
<div id="galleryAdd">
<form enctype="multipart/form-data" method="post" >
<!-- een hidden id meegeven voor de plaatsing -->
<input type="hidden" name="parentID" value="<? //$_GET['b']?>40">
<input type="submit" name="addImg" value="Toevoegen" />
</form>
</div>
<div id="addExisting"></div>
单击图像项时,javascript正在调用页面加载:
$('.imgItem').click(function() {
$('.imgItem').removeClass("image_select");
$(this).addClass("image_select");
var imgsource = $(this).find('img').attr('src'),
folderID = $(this).find('img').attr('rel');
$("#addExisting").load("ajax.addExisting.php", {parentID:folderID, imgsource:imgsource});
return false;
});
ajax.existing.php :单击图像时加载的页面
/* Algemene Gegevens bestand */
$bestand = $_POST['imgsource'];
/* Meta Gegevens bestand */
$file = substr($bestand, 0,strrpos($bestand,'.'));
$ext = substr(strrchr($bestand,'.'),1);
$base = basename($file);
if(isset($_POST['addImg'])){
/* Parent */
$queryParent = mysql_query("SELECT * FROM `image_folders` WHERE id = ".$_POST['parentID']."");
$parent = mysql_fetch_assoc($queryParent);
$bestand_folder = "../../images/".$parent['dirname']."/";
mysql_query("INSERT INTO images (positie, parent, parentID, naam, alt, titel, extensie) VALUES ('99', '".$parent['name']."', '".$parent['id']."', '".$base."', '".$base."', '".$base."','".$ext."')")or die('kan niet uploaden'.mysql_error());
}