将数以千计的图片上传到Google搜索以获得更好的解决方案并下载 [英] Upload thousands of pics to Google searching for better resolution and downloading it
问题描述
代码输入是目录路径。
上传到Google并下载更好的解决方案如果有。
the code input is a directory path.
uploads to Google and downloads better resolution if there's.
推荐答案
使用此服务和将您的图片文字放入下面提到的链接{your + search + image} +符号表示间距 https://www.google.co.in/search?hl=en&site=imghp&tbm=isch& ; source = hp& biw = 1366& bih = 599& q = your + search + image [ ^ ]
Use this Service and put your Image text in the Link mentioned in the below {your+search+image} The + symbol indicates spacinghttps://www.google.co.in/search?hl=en&site=imghp&tbm=isch&source=hp&biw=1366&bih=599&q=your+search+image[^]
这是将图像上传到数据库的aspx页面样本设计
This is the aspx page sample design to upload the image to database
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Imagehandler.aspx.cs" Inherits="saavura.Imagehandler" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function validate() {
var result = false;
var upfile = document.getElementById("FileUpload1").value;
if (upfile != "") {
var accept = "png,gif,jpg,jpeg".split(',');
var getExtention = upfile.split('.');
var extention = getExtention[getExtention.length - 1];
for (i = 0; i < accept.length; i++) {
if (accept[i] == extention) {
result = true;
break;
}
}
if (!result) {
alert("allowed file extention are png,gif,jpg,jpeg");
}
}
else {
alert("select image to Upload");
}
return result;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUploadImage" runat="server"
onclientclick="return validate();" Text="UPLOADIMAGE TO DATABASE"
onclick="btnUploadImage_Click1" />
</td>
</tr>
</table>
</div>
<div>
<asp:GridView ID="gvImages" CssClass="Gridview" runat="server" AutoGenerateColumns="False"
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="white">
<Columns>
<asp:BoundField HeaderText = "Image Name" DataField="Id" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("Id") %>' Height="150px" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
这个aspx的cs页面在这里..
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System .Web.UI;
使用System.Web.UI.WebControls;
使用System.Data;
使用System.Data.SqlClient;
使用System.Collections;
使用System.IO;
使用System.Configuration;
命名空间imagehand_and_crystalrep
{
公共部分类Imagehandler:System.Web.UI .Page
{
// string strcon = ConfigurationManager.ConnectionStrings [dbconnection]。ConnectionString;
SqlConnection con = new SqlConnection(@Server = .\sqlexpress; Initial Catalog = myapptest; User Id = sa; Password = sa123);
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
BindGridData();
}
}
protected void btnUploadImage_Click1(object sender, EventArgs e)
{
if(FileUpload1.PostedFile.ContentType.ToLower()。StartsWith(image)&&
FileUpload1.HasFile)
{
Hashtable imageHash = new Hashtable();
imageHash.Add(@ imageData,FileUpload1.FileBytes);
con.Open();
SqlCommand cmd = new SqlCommand(sp_UploadImage2,con);
//cmd.Parameters.Add(\"@ imageData,SqlDbType.Image).Value = imageHash [@ imageData];
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter (@ imageData,SqlDbType.Image))。Value = imageHash [@ imageData];
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect(imagehandler.aspx);
}
private void BindGridData()
{
SqlCommand command = new SqlCommand(SELECT Image,ID from images,con) ;
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add(bordercolor,black);
}
}
}
Imagehandler.ashx是图像处理从设计到cs页面的页面处理请求页面,这是必要的......
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
使用System.Data;
使用System。 Data.SqlClient;
使用System.Collections;
使用System.IO;
使用System.Configuration;
命名空间imagehand_and_crystalrep
{
公共部分类Imagehandler:System.Web.UI .Page
{
// string strcon = ConfigurationManager.ConnectionStrings [dbconnection]。ConnectionString;
SqlConnection con = new SqlConnection(@Server = .\sqlexpress; Initial Catalog = myapptest; User Id = sa; Password = sa123);
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
BindGridData();
}
}
protected void btnUploadImage_Click1(object sender, EventArgs e)
{
if(FileUpload1.PostedFile.ContentType.ToLower()。StartsWith(image)&&
FileUpload1.HasFile)
{
Hashtable imageHash = new Hashtable();
imageHash.Add(@ imageData,FileUpload1.FileBytes);
con.Open();
SqlCommand cmd = new SqlCommand(sp_UploadImage2,con);
//cmd.Parameters.Add(\"@ imageData,SqlDbType.Image).Value = imageHash [@ imageData];
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter (@ imageData,SqlDbType.Image))。Value = imageHash [@ imageData];
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect(imagehandler.aspx);
}
private void BindGridData()
{
SqlCommand command = new SqlCommand(SELECT Image,ID from images,con) ;
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add(bordercolor,black);
}
}
}
The cs page of this aspx is below here..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.IO;
using System.Configuration;
namespace imagehand_and_crystalrep
{
public partial class Imagehandler : System.Web.UI.Page
{
//string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
SqlConnection con = new SqlConnection(@"Server=.\sqlexpress;Initial Catalog=myapptest;User Id=sa;Password=sa123");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
protected void btnUploadImage_Click1(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.ContentType.ToLower().StartsWith("image") &&
FileUpload1.HasFile)
{
Hashtable imageHash = new Hashtable();
imageHash.Add("@imageData", FileUpload1.FileBytes);
con.Open();
SqlCommand cmd = new SqlCommand("sp_UploadImage2", con);
//cmd.Parameters.Add("@imageData", SqlDbType.Image).Value = imageHash["@imageData"];
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@imageData", SqlDbType.Image)).Value = imageHash["@imageData"];
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect("imagehandler.aspx");
}
private void BindGridData()
{
SqlCommand command = new SqlCommand("SELECT Image,ID from Images", con);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add("bordercolor", "black");
}
}
}
The Imagehandler.ashx is the page processing request page for image to process from design to cs page which is necessary...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.IO;
using System.Configuration;
namespace imagehand_and_crystalrep
{
public partial class Imagehandler : System.Web.UI.Page
{
//string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
SqlConnection con = new SqlConnection(@"Server=.\sqlexpress;Initial Catalog=myapptest;User Id=sa;Password=sa123");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
protected void btnUploadImage_Click1(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.ContentType.ToLower().StartsWith("image") &&
FileUpload1.HasFile)
{
Hashtable imageHash = new Hashtable();
imageHash.Add("@imageData", FileUpload1.FileBytes);
con.Open();
SqlCommand cmd = new SqlCommand("sp_UploadImage2", con);
//cmd.Parameters.Add("@imageData", SqlDbType.Image).Value = imageHash["@imageData"];
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@imageData", SqlDbType.Image)).Value = imageHash["@imageData"];
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect("imagehandler.aspx");
}
private void BindGridData()
{
SqlCommand command = new SqlCommand("SELECT Image,ID from Images", con);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add("bordercolor", "black");
}
}
}
这篇关于将数以千计的图片上传到Google搜索以获得更好的解决方案并下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!