hello...

in my site i want to do search images from google and put a link to each image "upload this image". when i click this link automatically upload this image in to my site. i searched a lot after i found this script. but how to add link and how to upload this image into my folder. here is the code...please anybody help.

<!--
  copyright (c) 2009 Google inc.

  You are free to copy and use this sample.
  License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google AJAX Search API Sample</title>
    <script src="http://www.google.com/jsapi?key="enter your google key" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    *  How to search for images and filter them by color.
    */
    
    google.load('search', '1');
    
    function OnLoad() {
      var searchControlDiv = document.getElementById("content");
      var control = new GSearchControl();
      control.setResultSetSize(GSearch.LARGE_RESULTSET);
      control.setLinkTarget(GSearch.LINK_TARGET_PARENT);
    
      var options = new GsearcherOptions();
      options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
    
      var isearcher;
      var colors = [
        GimageSearch.COLOR_RED,
        GimageSearch.COLOR_ORANGE,
        GimageSearch.COLOR_YELLOW,
        GimageSearch.COLOR_GREEN,
        GimageSearch.COLOR_TEAL,
        GimageSearch.COLOR_BLUE,
        GimageSearch.COLOR_PURPLE,
        GimageSearch.COLOR_PINK,
        GimageSearch.COLOR_WHITE,
        GimageSearch.COLOR_GRAY,
        GimageSearch.COLOR_BLACK,
        GimageSearch.COLOR_BROWN
      ];
      
      for (var i=0; i < colors.length; i++) {
        var colorSearcher = new google.search.ImageSearch();
        colorSearcher.setRestriction(GimageSearch.RESTRICT_COLORFILTER,
                                     colors[i]);
        var colorName = colors[i].substring(0,1).toUpperCase() + colors[i].substring(1);
        colorSearcher.setUserDefinedLabel(colorName);
        control.addSearcher(colorSearcher, options);
      };
    
      // tell the searcher to draw itself and tell it where to attach
      var drawOptions = new google.search.DrawOptions();
      drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
      control.draw(searchControlDiv, drawOptions);
      control.execute("rings");
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
    <style type="text/css" media="screen">
      body, table, p{
        background-color: white;
        font-family: Arial, sans-serif;
        font-size: 13px;
      }

      .gsc-trailing-more-results {
        display : none;
      }

      .gsc-resultsHeader {
        display : none;
      }

      .gsc-results {
        padding-left : 20px;
      }

      .gsc-control {
        width : 800px;
      }

      .gsc-tabsArea {
        margin-bottom : 5px;
      }
    </style>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="content">Loading...</div>
  </body>
</html>

Recommended Answers

All 4 Replies

Be careful. Allowing to upload any picture to your server, may violate copyright. That you can find the image with Google, does not mean it is free to use.

thanks for your reply. can i use this functionality in my site only for search images from google (not for download in to my site)?

<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google AJAX Search API Sample</title>
    <script src="http://www.google.com/jsapi?key=ABQIAAAAgSCBPKKXLaFLCa0zYhK_bRTmtuFi8keFPXfiskexcVlSZF94xxRUJLROXxEZQMSUmMfmtEqszwZupQ" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    *  The Hello World of the AJAX Search API
    */

    google.load('search', '1');

    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();

       // Add in a WebSearch
      var webSearch = new google.search.WebSearch();

       // Restrict our search to pages from our CSE
      webSearch.setSiteRestriction('008390820862037836276:cbpkunwzivc', 'lectures');



      // Add the searcher to the SearchControl
      searchControl.addSearcher(webSearch);

      // Add in a full set of searchers
      searchControl.addSearcher(new google.search.ImageSearch());
      searchControl.addSearcher(new google.search.VideoSearch());
      searchControl.addSearcher(new google.search.WebSearch());  
      searchControl.addSearcher(new google.search.NewsSearch());
      searchControl.addSearcher(new google.search.BlogSearch());            
      searchControl.addSearcher(new google.search.BookSearch());
      var localSearch = new google.search.LocalSearch();
      searchControl.addSearcher(localSearch);
      searchControl.addSearcher(new google.search.PatentSearch());

      // Set the Local Search center point
      localSearch.setCenterPoint("New York, NY");

      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("content"));

      // execute an inital search
      searchControl.execute("Sasha Grey as model");
    }

    google.setOnLoadCallback(OnLoad);

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

Aussi simple que ça.et en complément va à la Source. http://code.google.com/apis/ajax/playground/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.