1

您好,我正在使用图像浏览器,其中有一个提交按钮以向数据库添加新行。不幸的是,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());

  }
4

2 回答 2

1

但是您没有发布addImg.

您只发送到 ajax 页面{parentID:folderID, imgsource:imgsource}

改变

$("#addExisting").load("ajax.addExisting.php", {
                              parentID:folderID, 
                              imgsource:imgsource});

$("#addExisting").load("ajax.addExisting.php", {
                              parentID:folderID, 
                              imgsource:imgsource,  
                              addImg:'Toevoegen'});
于 2012-10-02T09:17:19.497 回答
0

您没有在通话中发送该addImg字段。.load()您发送的唯一字段是parentIDimgsource。如果需要addImg,请将其添加到.load().

于 2012-10-02T09:17:49.853 回答