社区
Web 开发
帖子详情
在HTTP里怎么传送图片啊?
strolls
2004-04-02 03:14:41
规定一个接口
要要求把图片和图片的类型一起传送过去
怎么样实现发送和接收啊?
...全文
227
4
打赏
收藏
在HTTP里怎么传送图片啊?
规定一个接口 要要求把图片和图片的类型一起传送过去 怎么样实现发送和接收啊?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
thinkinlove
2004-04-02
打赏
举报
回复
顶下强人的
gjd111686
2004-04-02
打赏
举报
回复
<%@ page contentType="text/html; charset=gb2312"%>
<%@ include file="/DataIni/DataOpen.jsp"%>
<%@ include file="/ScriptLib/Init.jsp"%>
<%
InputStream InData=null;
int iSize,iLength;
iLength=request.getContentLength();
byte[] Buffer=new byte[iLength];
byte[] Byte_File;
if(iLength>0)
{
InData=request.getInputStream();
String ContentType=request.getContentType();
iSize=InData.read(Buffer);
if(iSize!=-1)
{
//数据处理开始
String FileData=new String(Buffer);
//正则字串:"name=\"";
//正则字串:"filename=\"";
String strSplit=ContentType.substring(ContentType.lastIndexOf("=")+1,ContentType.length());
String strSub[]=FileData.split(strSplit);
String strElement;
int iBegin,iEnd;
iBegin=0;iEnd=0;
String FieldName,FieldValue;
int bTrue;
bTrue=0;
int iPos;
iPos=0;
int iLocation;
iLocation=0;
for(int iIndex=0;iIndex<strSub.length;iIndex++)
{
strElement=strSub[iIndex];
iBegin=strElement.indexOf("name=\"",0);
if(iBegin!=-1)
{
iEnd=strElement.indexOf("\"",iBegin+6);
FieldName=strElement.substring(iBegin+6,iEnd);
iBegin=strElement.indexOf("filename=\"",0);
if(iBegin!=-1)
{
bTrue=1;
}
//
iEnd=strElement.indexOf("\r\n\r\n",0);
if(bTrue==1)
{
iLocation=0;
iPos=FileData.indexOf("filename=\"",iPos);
iPos=FileData.indexOf("\n",iPos)+1;
iPos=FileData.indexOf("\n",iPos)+1;
iPos=FileData.indexOf("\n",iPos)+1;
iLocation=FileData.indexOf(strSplit,iPos)-4;
FieldValue=FileData.substring(iPos,iLocation);
byte[] Byte_File_=FieldValue.getBytes();
Byte_File=new byte[Byte_File_.length];
for(int kIndex=0;kIndex<Byte_File_.length;kIndex++)
{
Byte_File[kIndex]=Buffer[iPos+0+kIndex];
//0:Excel
//0:Word
//
}
session.putValue(FieldName,Byte_File);
}
else
{
FieldValue=strElement.substring(iEnd+4);
session.putValue(FieldName,FieldValue.substring(0,FieldValue.indexOf("\n")-1));
}
bTrue=0;
}
}
//数据处理结束
String TypeValue,Id;
TypeValue=(String)session.getValue("TypeValue");
if(TypeValue!=null)
{
int iDoAction;
iDoAction=0;
if(TypeValue.indexOf("Add",0)!=-1)
{iDoAction=1;}
if(TypeValue.indexOf("Modify")!=-1)
{iDoAction=2;}
if(TypeValue.indexOf("Del")!=-1)
{iDoAction=3;}
odbcQuery="";
Id=(String)session.getValue("RecordId");
boolean bDefault;
int iC;
oracle.sql.BLOB m_Blob;
switch(iDoAction)
{
case 1:
bDefault=odbcConn.getAutoCommit();
odbcConn.setAutoCommit(false);
odbcStmt.executeUpdate("insert into MediaLib(ID,Category,Type,MediaFile,Remark) values(IDSERIAL.nextval,'"+(String)session.getValue("Category")+"','"+(String)session.getValue("Type")+"',EMPTY_BLOB(),'"+(String)session.getValue("Remark")+"')");
odbcQuery="select * from MediaLib order by ID asc";
odbcRs=odbcStmt___.executeQuery(odbcQuery);
odbcRs.last();
String iID=String.valueOf((int)odbcRs.getInt("ID"));
odbcQuery="select MediaFile from MediaLib where ID="+iID+" for Update";
odbcRs=odbcStmt___.executeQuery(odbcQuery);
odbcRs.last();
m_Blob=(oracle.sql.BLOB)odbcRs.getBlob("MediaFile");
BufferedOutputStream pOutAdd=new BufferedOutputStream(m_Blob.getBinaryOutputStream());
ByteArrayInputStream pInAdd=new ByteArrayInputStream((byte[])session.getValue("MediaFile"));
while((iC=pInAdd.read())!=-1)
{pOutAdd.write(iC);}
pInAdd.close();
pOutAdd.close();
odbcConn.commit();
odbcConn.setAutoCommit(bDefault);
response.sendRedirect("/System/Media/List.jsp");
break;
case 2:
bDefault=odbcConn.getAutoCommit();
odbcConn.setAutoCommit(false);
odbcStmt.executeUpdate("update MediaLib set MediaFile=EMPTY_BLOB() where ID="+Id);
odbcRs=odbcStmt___.executeQuery(odbcQuery);
odbcRs.last();
m_Blob=(oracle.sql.BLOB)odbcRs.getBlob("MediaFile");
BufferedOutputStream pOutModify=new BufferedOutputStream(m_Blob.getBinaryOutputStream());
ByteArrayInputStream pInModify=new ByteArrayInputStream((byte[])session.getValue("MediaFile"));
while((iC=pInModify.read())!=-1)
{pOutModify.write(iC);}
pInModify.close();
pOutModify.close();
odbcConn.commit();
odbcConn.setAutoCommit(bDefault);
response.sendRedirect("/System/Media/List.jsp");
break;
case 3:
odbcStmt.executeUpdate("delete from MediaLib where ID="+Id);
response.sendRedirect("/System/Media/List.jsp");
break;
}
}
}
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css">
</head>
<body onload="window.alert('动作失败,系统取消操作!');window.location.href='/System/Media/List.jsp';">
<%@ include file="/TemplateLib/Head.jsp"%>
<%@ include file="/TemplateLib/Tail.jsp"%>
<%@ include file="/DataIni/DataClose.jsp"%>
</body>
</html>
gjd111686
2004-04-02
打赏
举报
回复
<%@ page contentType="text/html; charset=gb2312"%>
<%@ include file="/DataIni/DataOpen.jsp"%>
<%@ include file="/ScriptLib/Init.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css">
<script>
function MediaSubmit(TypeValue,Id)
{
MediaForm.TypeValue.value=TypeValue;
MediaForm.RecordId.value=Id;
MediaForm.submit();
}
function ShowMedia(Id,Type)
{
var hwnd=window.open('','','');
switch(Type)
{
case "image/*":
hwnd.document.write("<Img src='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0></a>");
break;
case "audio/*":
hwnd.document.write("<BgSound src='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0>");
break;
case "video/*":
hwnd.document.write("<Img dynsrc='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0></a>");
break;
case "application/msword":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
case "application/vnd.ms-excel":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
case "application/*":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
default:
break;
}
}
</script>
</head>
<body>
<%@ include file="/TemplateLib/Head.jsp"%>
<center>
<form action="Result.jsp" method="post" name="MediaForm" enctype="multipart/form-data">
<input type="hidden" name="TypeValue" size="10" value="">
<input type="hidden" name="RecordId" size="10" value="">
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="10%" class="TdClass_Head">多媒体库</td>
</tr>
</table>
<br>
<table border="0" width="80%" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" class="TdClass_0">媒体描述</td>
<td width="30%" class="TdClass_0">媒体分类</td>
<td width="10%" class="TdClass_0">媒体类型</td>
<td width="40%" class="TdClass_0">媒体文件</td>
<td width="10%" class="TdClass_0">执行操作</td>
</tr>
<tr>
<td width="10%" class="TdClass_1"><input name="Remark" size="10" value=""></td>
<td width="30%" class="TdClass_1">
<select name="Category" size=1 style="width:80%">
<option value="">--请选择--</option>
<%
odbcQuery="select distinct Category from MediaLib";
odbcRs=odbcStmt.executeQuery(odbcQuery);
String Category;
while(odbcRs.next())
{
Category=odbcRs.getString("Category");
%>
<option value="<%=Category%>"><%=Category%></option>
<%
}
odbcRs.close();
%>
</select>
<script>
function AddCategory()
{
var m_Category="";
m_Category=window.prompt("请输入媒体分类","");
if(m_Category!="")
{
MediaForm.Category.length=MediaForm.Category.length+1;
MediaForm.Category.options[MediaForm.Category.length-1].text=m_Category;
MediaForm.Category.options[MediaForm.Category.length-1].value=m_Category;
MediaForm.Category.options[MediaForm.Category.length-1].selected="selected";
}
}
</script>
<input type="button" value="." id="" name="" onclick="AddCategory()">
</td>
<td width="20%" class="TdClass_1">
<select name="Type" size=1 style="width:80%">
<option value="">--请选择--</option>
<option value="image/*">图像</option>
<option value="audio/*">音频</option>
<option value="video/*">视频</option>
<option value="application/msword">文档</option>
<option value="application/vnd.ms-excel">表格</option>
<option value="application/*">应用</option>
</select>
</td>
<td width="30%" class="TdClass_1"><input type="file" name="MediaFile" size="10" value=""><a href="#">浏览媒体</a></td>
<td width="10%" class="TdClass_1"><input type="button" onclick="MediaSubmit('Add','NULL')" value="增加" id=Add name=Add></td>
</tr>
<%
odbcQuery="select * from MediaLib";
odbcRs_=odbcStmt.executeQuery(odbcQuery);
String Id,Type;
int iCount;
iCount=0;
while(odbcRs_.next())
{
Id=odbcRs_.getString("ID");
Type=odbcRs_.getString("Type");
if(iCount%2==0)
{
%>
<tr>
<td width="10%" class="TdClass_0"><input name="Remark<%=Id%>" size="10" value="<%=odbcRs_.getString("Remark")%>"></td>
<td width="30%" class="TdClass_0"><input name="Category<%=Id%>" size="10" value="<%=odbcRs_.getString("Category")%>" readonly></td>
<td width="10%" class="TdClass_0"><input name="Type<%=Id%>" size="10" value="<%=Type%>" readonly></td>
<td width="40%" class="TdClass_0"><input type="file" name="MediaFile<%=Id%>" size="10" value=""><a href="#" onclick="ShowMedia('<%=Id%>','<%=Type%>')">浏览媒体</a></td>
<td width="10%" class="TdClass_0"><input type="button" onclick="MediaSubmit('Modify','<%=Id%>')" value="修改" id=Modify name=Modify><input type="button" onclick="MediaSubmit('Del','<%=Id%>')" value="删除" id=Del name=Del></td>
</tr>
<% }else{%>
<tr>
<td width="10%" class="TdClass_1"><input name="Remark<%=Id%>" size="10" value="<%=odbcRs_.getString("Remark")%>"></td>
<td width="30%" class="TdClass_1"><input name="Category<%=Id%>" size="10" value="<%=odbcRs_.getString("Category")%>" readonly></td>
<td width="10%" class="TdClass_1"><input name="Type<%=Id%>" size="10" value="<%=Type%>" readonly></td>
<td width="40%" class="TdClass_1"><input type="file" name="MediaFile<%=Id%>" size="10" value=""><a href="#" onclick="ShowMedia('<%=Id%>','<%=Type%>')">浏览媒体</a></td>
<td width="10%" class="TdClass_1"><input type="button" onclick="MediaSubmit('Modify','<%=Id%>')" value="修改" id=Modify name=Modify><input type="button" onclick="MediaSubmit('Del','<%=Id%>')" value="删除" id=Del name=Del></td>
</tr>
<%
}
iCount++;
}
odbcRs_.close();
%>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" class="TdClass_Head"><input type="button" value="返回" id="Return" name="Return" onclick="window.location.href='/System/Index.jsp'"></td>
</tr>
</table>
</form>
</center>
<%@ include file="/TemplateLib/Tail.jsp"%>
<%@ include file="/DataIni/DataClose.jsp"%>
</body>
</html>
gjd111686
2004-04-02
打赏
举报
回复
根据RFC1867将图片上传
vc客户端通过
HTTP
的POST方式
传送
文件到PHP服务器
同时具有客户端和服务器端代码。 VC客户端模拟
HTTP
协议POST方式
传送
文件到WEB服务器 服务器端用PHP写的,实现简单的保存文件。 要2分不算多吧?呵呵
Android --- 夜神模拟器中没有
图片
怎么办?夜神模拟器中怎么导入
图片
?
夜神模拟器中怎么导入
图片
? 解决: 1.点击右侧文件助手 2.点击“打开电脑文件夹” 3.弹出如下文件夹 4.点击imageShare 5.点击Screenshots(这个是截图文件夹) 6.将你准备好的
图片
导入这个目录下 7.重启夜神...
Http
服务器如何在
HTTP
response中
传送
二进制
图片
要想知道如何
传送
这些二进制,先来点二进制文件的背景知识 文件魔数 magic number: 操作系统的文件,其起始的几个字节的内容是固定的。根据这几个字节的内容就可以确定文件类型,因此这几个字节的内容被...
网站开发(一)
http
和
http
s的区别
http
是什么?
http
协议的特性
http
与
http
s网站通信协议两者的有什么不同呢?
二、
HTTP
是什么? 1、
HTTP
发展阶段 2、
HTTP
工作原理 3、
HTTP
的工作特性 三、
HTTP
和
HTTP
S区别 1、
http
与
http
s端口不同 2、
http
和
http
s应用 ? ? ? ? 2.1
http
应用 ? ? ? ? 2.2
http
s应用 3、
http
和
http
s区别简易图 ...
Qt使用socket
传送
图片
项目中用到需要在Qt下使用socket
传送
图片
,网上查了一些资料,发现没有适合。自己写了一段代码,记录在这
里
。 使用socket
传送
图片
会出现
图片
过大需要分包的问题。有两种解决方法:一种是发送的时候分几个包发送,...
Web 开发
81,092
社区成员
341,716
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章