jQuery美元.Ajax和PHP来删除文件


jQuery $.ajax and php to delete a file

我试图删除一个文件与jQuery的$.ajax和php。我有以下几点。

/js/whatever.js

$('.deleteimage').live('click', function() {
    $imagefile = 'http://domain.com/images/1/whatever.jpg';
    $imagethumb = 'http://domain.com/images/1/thumbnail/whatever.jpg';
    $.ajax({
        type: 'POST',
        data: {
            action: 'deleteimage',
            imagefile: $imagefile,
            imagethumb: $imagethumb,
        },
        url: 'script.php',
        success: function(msg) {
            alert(msg);
        }
    })
})

/php/script.php

<?php
    if($_GET["action"]=="deleteimage")
    {
        $imagefile = $_REQUEST['imagefile'];
        $imagethumb = $_REQUEST['imagethumb'];
        $imagefileend = '../images'.end(explode('images',$imagefile)); //This will get me the path to the image ../images/1/whatever.jpg without the domain which is the correct path to the file. I tried that path directly and it deleted the file. 
        $imagethumbend = '../images'.end(explode('images',$imagethumb));
        unlink($imagefileend);
        unlink($imagethumbend);
    }
?>

所有路径都正确。在firebug中,我看到post变量被正确地发送到script.php,但是文件没有被删除。我做错了什么?

在jQuery中使用POST,而在PHP中使用GET。改成if($_POST["action"]=="deleteimage"),请不要用$_REQUEST,用$_POST