Hi, I am new in programing, I want to save images from google-images, I can use filter for only use the free ones. I use a google API, I have the URL and I want to pass to php, but I dont know how to pass from java-script to php. I try with forms, and document.write('<a href="prueba4.php?url1=unescapedUrl">save the image</a>'); but doesn't work google.

function MyKeepHandler(result) {
// clone the result html node
var node = result.html.cloneNode(true);
 // attach it
var savedResults = document.getElementById("content");
// 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);

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.setOnKeepCallback(this, MyKeepHandler);
// execute an inital search

 <body style="font-family: Arial;border: 0 none;">
<div id="content">Loading...</div>

for saving image I was using this (this works if I use URL-name:

function saveImage($url,$path) {
	    $c = curl_init();
	    $s = curl_exec($c);
	    $f = fopen($path, 'wb');
	    $z = fwrite($f,$s);
	    if ($z != false) return true;
	    return false;

Please help me, I am alone and I dont know anyone else...I am in china and I dont speak chine

Your code seems ok to me, but why do you have var_dump($x); inside your javascript? var_dump() it's PHP, you need console.log there, or alert as you already wrote. And also you need to change your document.write to integrate the var as you did in the alert: document.write('<a href="' + unescapedUrl + '">save the image</a>'); bye :)

commented: THANKS SO MUCH +0

Thank you for helping me, it works, I am new in programing and I could not see the error. I am happy now. Have a good day, you help someone :):icon_smile: