⑴ c/s模式下,客户端如何显示服务器端固定文件夹下的一张图片
添加images控件,将url改为服务器图片地址即可显示,如:\\server\images\1.jpg
⑵ PHP在服务器端怎么显示图片呢
貌似没这功能 你如果想这样的话可以把url传到数据库 在遍历出来就行了
⑶ java实现图片上传至服务器并显示,如何做
给你段代码,是用来在ie上显示图片的(servlet):
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id = request.getParameter("id");
File file = new File(getServletContext().getRealPath("/")+"out"+"/"+id+".gif");
response.setCharacterEncoding("gb2312");
response.setContentType("doc");
response.setHeader("Content-Disposition", "attachment; filename=" + new String(file.getName().getBytes("gb2312"),"iso8859-1"));
System.out.println(new String(file.getName().getBytes("gb2312"),"gb2312"));
OutputStream output = null;
FileInputStream fis = null;
try
{
output = response.getOutputStream();
fis = new FileInputStream(file);
byte[] b = new byte[1024];
int i = 0;
while((i = fis.read(b))!=-1)
{
output.write(b, 0, i);
}
output.write(b, 0, b.length);
output.flush();
response.flushBuffer();
}
catch(Exception e)
{
System.out.println("Error!");
e.printStackTrace();
}
finally
{
if(fis != null)
{
fis.close();
fis = null;
}
if(output != null)
{
output.close();
output = null;
}
}
}
这个程序的功能是根据传入的文件名(id),来为浏览器返回图片流,显示在<img>标签里
标签的格式写成如下:
<img src="http://localhost:8080/app/preview?id=111 "/><br/>
显示的是111.gif这个图片
你上面的问题:
1.我觉得你的第二个办法是对的,我们也是这样做的,需要的是把数据库的记录id号传进servlet,然后读取这条记录中的路径信息,生成流以后返回就是了
关于上传文件的问题,我记得java中应该专门有个负责文件上传的类,你调用就行了,上传后存储在指定的目录里,以实体文件的形式存放
你可以参考这个:
http://blog.csdn.net/arielxp/archive/2004/09/28/119592.aspx
回复:
1.是的,在response中写入流就行了
2.是发到servlet中的,我们一般都是写成servlet,短小精悍,使用起来方便,struts应该也可以,只是我没有试过,恩,你理解的很对
⑷ 客户端jsp如何显示服务器中的图片
用真实路径的话容易暴露你的服务器的数据位置。
一般我们的是在服务器上读取图片流,然后使用imag标签的src来请求图片流来显示图片
⑸ 怎么把ftp服务器的图片在网页中显示不是本地显示的
亲,FTP上传上去了之后hi在服务器上去了, 你要把图片也上传上传上去,图片的位置跟你本地一样的。路径就好了,,或者是你把图片上传了之后去修改下 路径。3951
⑹ 服务器中网站都设置好了,但在电脑上打开网站图片不能显示
原因:图片路径问题;
解决方法:
1.对图片路径进行重新配置,基本这种情况80%都是路径问题;
2.修改部分路径做测试,看能否显示出来,最后哪个图片显示出来,就按那个路径设置;
3.还有就是确定你将图片文件上传了吗?