附件控制文件(图像文件)使用JavaScript调整大小 [英] Attachment control file(image file) resize using JavaScript

查看:68
本文介绍了附件控制文件(图像文件)使用JavaScript调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是调整附件图像文件的大小。


当用户在附件控件中附加图像文件时,如果文件大于2MB,那么我必须调整大小使用JavaScript的图像最终会降低图像大小。调整大小应该在用户点击"提交/确定"之前进行。按钮
,以便调整大小图像上传到SharePoint列表但不上载到原始图像。这意味着,我必须调整大小并将其附加回附件控件?


我的确实现了这几乎对Canvas对象上的图像大小调整,但不确定如何将其附加回SharePoint附件控制。那会有用吗?或者,我是否需要在Canvas上保留它并在用户单击"提交"并删除原始
附件时调用REST API?如果可行,我会依赖第一个解决方案。


为了调整大小,我正在触发fileReader.onload事件。我的部分脚本代码是


fileReader.onload = function (event){

解决方案

在这里,您可以看到以下链接


https://sharepoint.stackexchange.com/questions/232032/list-and-change-image-size



这是SSOM


https://chanakyajayabalan.wordpress.com/2009/11/17 /缩放-的图像·维持同时加入-AS-一个附着到一个列表项/


Objective is to resize the attachment image file size.

When user attaches a image file in an attachment control then if the file is greater than 2MB then I have to resize the image using JavaScript which will eventually lower the image size. Resizing should happen before user click "Submit/OK" button so that resize image gets uploaded to SharePoint list but not the original image. Which means, I have to resize and attach it back to the attachment control?

I did implemented this almost to the image resize on Canvas object but not sure how to attach it back to SharePoint attachment control. Will that work? OR do i need to keep it as is on Canvas and call REST API when user click on Submit and remove the original attachments? I am banking on first solution if it is feasible.

For resizing I am triggering fileReader.onload event. Part of my script code is

fileReader.onload = function (event) {

解决方案

Here you see the links below

https://sharepoint.stackexchange.com/questions/232032/list-and-change-image-size

This is SSOM

https://chanakyajayabalan.wordpress.com/2009/11/17/resizing-an-image-while-adding-as-an-attachment-to-a-list-item/


这篇关于附件控制文件(图像文件)使用JavaScript调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆