最近的一个项目分成web site和 admin site2个站点.然后就遇到一个web下new sign permit,然后到admin下审批的问题.问题的关键在于web下的那个功能有个上传文件的功能.文件可能是image,也可以是doc,pdf,如果是image就需要display.
问题在于2个站点并不能共享upload目录,也就是web上传的,admin并不能访问.查询了相关资料以后有以下几个解决方案:
1.存数据库2进制流,读取都方便
2.存IO stream, 存在服务器physical path,这样就不用care共享的问题了,2边都往同一个目录下upload.
第2个方法就有个读取显示图片的问题.不在server控制的目录下如何显示图片呢.显然不能简单的<image src="xxx.img" />,不可能简单的把物理路径写在image标签里,到了客户端根本没办法解析.这里就得用IO stream把图片取成 byte,然后response到一个单独的页面上
step1:
create empty page, in the page write init function
private void createImage(String imagePath)
{
if (imagePath != null && imagePath != String.Empty)
{
Response.ContentType = "image/jpeg";
byte[] bytes = null;
Stream stream = null;
try
{
stream = new FileStream(imagePath, FileMode.Open);
using (MemoryStream ms = new MemoryStream())
{
int b;
while ((b = stream.ReadByte()) != -1)
{
ms.WriteByte((byte)b);
}
bytes = ms.ToArray();
}
Response.BinaryWrite(bytes);
Response.Flush();
}
catch (Exception ex)
{
bytes = null;
}
finally
{
if (stream != null)
stream.Close();
}
}
}
这样就可以产生一个显示图片的页面
step 2: 把这个页面的url放到<image src="viewImage.aspx?"imagePath="xxx" />
这样就可以显示图片了.
另外download也可以用上面的strem做,只需要加上
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
Response.ContentType = type;
分享到:
相关推荐
yolov8系列--Use Deepstream python API to extract the model o
ffmpeg
v-使用编辑图像 v-use-edit-image是Vue合成API库,用于使用canvas API编辑图像。 您可以像这样蒙版图像! 而且,您可以裁剪,插入字符串并在图像上方绘制图像。 (当前,此回购仅包含掩码示例...对不起!) :rocket:...
npm install use-image 用法 import React from 'react' ; import { Image } from 'react-konva' ; import useImage from 'use-image' ; const url = 'https://konvajs.github.io/assets/yoda.jpg' ; function ...
Adaptive color image watermarking by the use of quaternion image moments
fusing of pancromatic and multispectral image
通过本文档的描述可掌握SRIO的应用
you can just use it like this Canvas2Image.saveAsImage(canvasObj, width, height, type) Canvas2Image.saveAsPNG(canvasObj, width, height) Canvas2Image.saveAsJPEG(canvasObj, width, height) Canvas2...
PHPSocket.IO 是 socket....$io->on('connection', function($socket)use($io){ $socket->on('chat message', function($msg)use($io){ $io->emit('chat message', $msg); }); }); 标签:PHPSocket
Configuring the Glance servers to use Keystone Configuring Glance API to use Keystone Configuring Glance Registry to use Keystone The Glance Image Cache Managing the Glance Image Cache Configuration ...
MATLAB 图像处理原版英文资料,经典难得!从最基本的图像处理说起,内容翔实!
ImageJ user-guide
Language: English Format: PDF Year: 2018 Pages: 161 ISBN : 3030001288 This book constitutes the refereed ... deep learning for computed tomography, and deep learning for general image reconstruction.
Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful ...Kindly use the following links to use this library: In build.gradle (Project) allprojects { repositories {
Whether for computer evaluation of otherworldly terrain or the latest high definition 3D blockbuster, digital image processing involves the acquisition, analysis, and processing of visual information ...
IO 串口模拟程序,适用于与51等系列单片机
需要要用到Linux时可用use制作一个简单的PXE平台,比较基础的东西,供参考。
You’ll see the OpenCV algorithms and how to use them for image processing. The next section looks at advanced machine learning and deep learning methods for image processing and classification. You...
Features: Integrated with the VCL's TImage component Easy to use image viewer component with rubberbanding support Supports popular file formats: Comprehensive TIFF (Packbits, CCITT group 3, 1d and ...
a client for gank.io with use dagger2 MVP Rxjava 项目采用dagger2 MVP模式编写 Dev Android-Studio: 2.2 version Java version : Java8 SDK Tool: 24.0.2 version jackOptions: true Points MVP dagger2 ...