Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ctrv-upload
Advanced tools
最近要做一个ctrl+V 上传图片的组件。简单说就是,使用截屏工具截一张图,然后在某个元素上按ctrl+v操作,需要将截的图上床至服务端,服务端保存图片并返回对应的地址;所以封装了组件做这事,发布出来记录下。
手动截屏后,鼠标移动至某元素,按ctrlv进行图片上传。
由于代码中使用到clipboardData对象及paste事件,目前只能兼容到高版本Chrome,FireFox及IE 11。
npm install ctrv-upload
支持AMD与CommonJs的方式加载模块,
直接引入:<script src="xxx/ctrv-upload/index.js">
AMD: define(['xxx/ctrv-upload/index'],function(ctrlVUtil){});
COMMONJS: var ctrlVUtil = require("ctrv-upload");
var load1 = document.querySelector(".js-upload");
// 实例化即可
new ctrlVUtil({
uploadUrl: "server.php",
targetElement: load1,
isCompleteImg:false,
data:{
name:"alanzhang"
},
success:function(data){
alert("上传成功");
console.log(data);
},
error: function(error){
alert("上传失败");
}
});
名称 | 参数 | 默认值 |
---|---|---|
uploadUrl | 上传地址 | 需自定义 |
targetElement | 鼠标放在该元素上时,可响应ctrl+v操作 | document.querySelector(".js-upload") |
isCompleteImg | 上传图片base64的格式,false 表示只上传content部分,即不包括头信息data:image/jpg;base64 ,true表示上传完整的base64字符串 | false |
data | 需要上传的其他参数,json对象 | 空 |
success | 上传成功时的回调函数,其参数为接口返回的json对象 | - |
error | 上传成功时的回调函数,其参数为接口返回的json对象 | - |
ctrlVUtil(config)
构造函数,参数:
config
: 上传图片的相关参数,json对象,具体字段见参数说明。ctrlVUtil#alertMsg(content)
静态方法,用于弹出异常信息的提示,默认使用window.alert(content)
弹出提示;提供此方法用于使用者自定义弹出提示的样式。
content
:组件给出的异常提示信息FAQs
The npm package ctrv-upload receives a total of 0 weekly downloads. As such, ctrv-upload popularity was classified as not popular.
We found that ctrv-upload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.