Php 如何从Google保存图像

Php 如何从Google保存图像,php,javascript,Php,Javascript,我是编程新手。我想保存谷歌图片的图片。我只能使用免费的过滤器。我使用谷歌API,我有URL,我想把它传递给PHP,但我不知道如何把它从JavaScript传递到PHP。我用表单和document.write(“”)来尝试它但它不起作用 function MyKeepHandler(result) { // clone the result html node var node = result.html.cloneNode(true); // attach it

我是编程新手。我想保存谷歌图片的图片。我只能使用免费的过滤器。我使用谷歌API,我有URL,我想把它传递给PHP,但我不知道如何把它从JavaScript传递到PHP。我用表单和
document.write(“”)来尝试它但它不起作用

function MyKeepHandler(result) {
    // clone the result html node
    var node = result.html.cloneNode(true);
    // attach it
    var savedResults = document.getElementById("content");
    savedResults.appendChild(node);
    // extract some info from the result to show to get at the individual attributes.
    // see http://code.google.com/apis/ajaxsearch/documentation/reference.html
    var title = result.title;
    var unformattedtitle = result.titleNoFormatting;
    var content = result.content;
    var unescapedUrl = result.unescapedUrl;

    document.write('<a href="prueba4.php?url1=unescapedUrl">save the image</a>');
    // alert("Saving " + unformattedtitle + " " + unescapedUrl + " " + content);
    var_dump($x);
}

function OnLoad() {
    // Create a search control
    var searchControl = new google.search.SearchControl();
    // Add in a WebSearch
    var webSearch = new google.search.WebSearch();
    // Add in a full set of searchers
    searchControl.addSearcher(new google.search.ImageSearch());
    //var localSearch = new google.search.LocalSearch();
    // tell the searcher to draw itself and tell it where to attach
    searchControl.draw(document.getElementById("content"));
    searchControl.setOnKeepCallback(this, MyKeepHandler);
    // execute an inital search
    searchControl.execute("tomates");
}

google.setOnLoadCallback(OnLoad);
</script>

</head>
<body style="font-family: Arial;border: 0 none;">
<div id="content">Loading...</div>
</body>
</html>
我注意到一件事:

document.write('<a href="prueba4.php?url1=unescapedUrl">save the image</a>');
document.write(“”);
JavaScript中没有变量插值,因此将输出精确的文本。将其更改为:

document.write('<a href="prueba4.php?url1=' + unescapedUrl + '">save the image</a>');
document.write(“”);
我注意到一件事:

document.write('<a href="prueba4.php?url1=unescapedUrl">save the image</a>');
document.write(“”);
JavaScript中没有变量插值,因此将输出精确的文本。将其更改为:

document.write('<a href="prueba4.php?url1=' + unescapedUrl + '">save the image</a>');
document.write(“”);

非常感谢您的回答,您是对的,但我无法将url名称传递给php。它表示不存在url1变量。“注意:未定义变量:C:\server\www\imagenes\prueba4.php第16行的url1”将
$url1
更改为
$\u GET['url1']
Martin Dimitrov非常感谢!!!终于成功了!!!我很高兴。你是最棒的,今天我为你祈祷;)非常感谢您的回答,您是对的,但我无法将url名称传递给php。它表示不存在url1变量。“注意:未定义变量:C:\server\www\imagenes\prueba4.php第16行的url1”将
$url1
更改为
$\u GET['url1']
Martin Dimitrov非常感谢!!!终于成功了!!!我很高兴。你是最棒的,今天我为你祈祷;)