如何使用plupload保存两个不同尺寸的图像
How to save Images with two different dimensions using plupload
我使用Plupload插件上传多个图像,因为我们可以选择在客户端调整图像大小,我想上传原始大小的图像,并将它们保存到单独的文件夹和调整大小的图像到另一个文件夹。
谁能告诉我下一步该怎么做?下面是我的代码:Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim chunk As Integer = If(context.Request("chunk") IsNot Nothing, Integer.Parse(context.Request("chunk")), 0)
Dim fileName As String = If(context.Request("name") IsNot Nothing, context.Request("name"), String.Empty)
Dim fileUpload As HttpPostedFile = context.Request.Files(0)
Dim uploadPath = context.Server.MapPath("~/uploads")
Using fs = New FileStream(Path.Combine(uploadPath, fileName), If(chunk = 0, FileMode.Create, FileMode.Append))
Dim buffer = New Byte(fileUpload.InputStream.Length - 1) {}
fileUpload.InputStream.Read(buffer, 0, buffer.Length)
fs.Write(buffer, 0, buffer.Length)
End Using
context.Response.ContentType = "text/plain"
context.Response.Write("Success")
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
这是我的脚本代码:
<script type="text/javascript">
$(function () {
// Setup flash version
$("#flash_uploader").pluploadQueue({
// General settings
runtimes: 'flash',
url: 'upload.ashx',
max_file_size: '10mb',
chunk_size: '1mb',
unique_names: true,
filters: [
{ title: "Image files", extensions: "jpg" }
],
// Resize images on clientside if we can
resize: { width: 800, height: 600, quality: 90 },
// Flash settings
flash_swf_url: 'js/plupload.flash.swf',
init: { StateChanged: function (up) {
// Called when the state of the queue is changed
if (up.state == plupload.STOPPED) {
$("#btnSubmit").removeAttr("disabled");
}
}
}
});
var uploader = $('#flash_uploader').pluploadQueue();
uploader.bind('FileUploaded', function (up, file, res) {
$('#showfilelist').append("<div id=" + file.id + "><a href='uploads/" + file.target_name + "' target='_blank'><img src='uploads/" + file.target_name + "' border='0'/><br>" + file.name + "</a><br>(" + plupload.formatSize(file.size) + ") <span></span></div>");
});
});
</script>
// Resizing an image
// Inputs [ new image size (Height,Width), Origial file path & name, new file path & name ]
ResizeImage(int height,int width, string inputFile, string outputFile)
{
var img = Image.FromFile(inputFile);
Image imagThumb = null;
imagThumb = img.GetThumbnailImage(width, height, null, new IntPtr());
imagThumb.Save(outputFile);
}
输入和输出文件可以从您保存图像的路径
访问eg.var input = Server.MapPath("~/images/imagename");
相关文章:
- 单击时切换两个图像
- 一个具有两个图像按钮的表单在只能按下一个按钮的情况下发送两个按钮值
- 使用Javascript对象为具有两个背景图像的DIV设置样式时出现问题
- 如何通过一个onclick事件更改两个单独的图像
- 如何使用 jQuery 交换网页中的两个图像(连续两次点击)
- 选择最短的旋转来排列两个图像
- 在jQuery中创建两个图像之间的行
- 将两个图像合并为一个,并使用javascript进行溢出隐藏
- 淡入淡出两个图像[JavaScript]
- 从两个标记中查找静态地图图像坐标
- 带有两个带过渡的图像的随机幻灯片
- 单击按钮时交换两个图像
- 如何将两个渐弱的图像居中
- 任何比较两个不同位图图像并在javascript中检测不同区域的方法
- 一键在一个窗口中打开两个不同的链接图像
- 可以在Javascript中比较两个图像
- 如何保存带有两个图像的画布
- 如何查看两个图像源是否相等
- 如何在两个图像之间添加空间
- 一次两个滑动图像