当前位置:网站首页>Uploads labs range (with source code analysis) (under update)
Uploads labs range (with source code analysis) (under update)
2022-07-03 15:59:00 【Mung east corner】
pass-01
There is front-end validation

onsubmit: When submitting Forms Execute a paragraph when JavaScript. It only recognizes true perhaps false. If you don't return a value , The default is true

Write a picture of horse , The suffix is the picture suffix , then bp Just grab the bag and change it

Ant sword connection

Source code analysis
front end :

checkile() function
function checkFile() {
var file = document.getElementsByName('upload_file')[0].value;
if (file == null || file == "") {
alert(" Please select the file to upload !");
return false;
}
// Define the types of files allowed to be uploaded
var allow_ext = ".jpg|.png|.gif";
// Extract the type of uploaded file
var ext_name = file.substring(file.lastIndexOf("."));
// Determine whether the type of uploaded file is allowed to be uploaded
if (allow_ext.indexOf(ext_name + "|") == -1) {
var errMsg = " The file is not allowed to upload , Please upload " + allow_ext + " Files of type , The current file type is :" + ext_name;
alert(errMsg);
return false;
}
}First, through getElementsByName Get form elements , It also gets an array of classes , If you want to get an element accurately , You can use array subscripts to get , So here document.getElementsByName('upload_file')[0].value; You get the file name .
Back if Statement to determine whether the uploaded file is empty
substring() Method is used to extract characters that are mediated between two specified subscripts .
example :
var str="Hello world!";
document.write(str.substring(3)+"<br>");
document.write(str.substring(3,7));
---------------------------------------------------------------------
lo world!
lo w indexOf() Method to return the first occurrence of a specified string value in the string . lastIndexOf() Method to get the suffix Returns the last position of the specified value in the string that calls the method , If not, return -1. Look forward from the back of the string , from fromIndex Start at . The characters in the string are indexed from left to right . Index of the first character (index) yes 0, The index of the last character is stringName.length - 1. Example :
String name = "upload.doc";
// Get suffix
String sname = name.substring(name.lastIndexOf("."));
// get upload part
String fileName=name.substring(0,name.lastIndexOf("."));if (allow_ext.indexOf(ext_name + "|") == -1) , Find the suffix just extracted in the suffix that allows uploading , If you can't find it indexOf() Function will return -1, In this way, we can judge
边栏推荐
- VC下Unicode和ANSI互转,CStringW和std::string互转
- Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
- VS2017通过IP调试驱动(双机调试)
- The wonderful use of do{}while()
- Wechat payment -jsapi: code implementation (payment asynchronous callback, Chinese parameter solution)
- 请求头不同国家和语言的表示
- 坚持输出需要不断学习
- 【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
- Driver and application communication
- Microservice API gateway
猜你喜欢

秒杀系统1-登录功能

Redis在Windows以及Linux系统下的安装

子类隐藏父类的同名函数

Second kill system 3 - list of items and item details

Digital image processing -- popular understanding of corrosion and expansion

ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装

Unity功能——Unity离线文档下载及使用

Low level version of drawing interface (explain each step in detail)

Microservice - declarative interface call openfeign

Detailed explanation of string function and string function with unlimited length
随机推荐
How to use annotations such as @notnull to verify and handle global exceptions
First!! Is lancet hungry? Official documents
App移动端测试【5】文件的写入、读取
Microservices Seata distributed transactions
Create gradle project
《微服务设计》读书笔记(下)
do{}while()的妙用
Principles of several common IO models
秒杀系统3-商品列表和商品详情
Find mapping relationship
uploads-labs靶场(附源码分析)(更新中)
深度学习之三维重建
Backtracking method to solve batch job scheduling problem
Go语言自学系列 | golang中的if else语句
[系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解
驱动与应用程序通信
从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍
Microservices - load balancing ribbon
通过进程PID获取可执行文件路径(QueryFullProcessImageName)
Seckill system 3- product list and product details