


Uploaded images, image size verification, image preview effect code based on jquery_jquery
jquery implements uploaded images and image size verification, image preview effect code
Uploaded image verification
*/
function submit_upload_picture(){
var file = $('file_c').value;
if(!/.(gif|jpg |jpeg|png|gif|jpg|png)$/.test(file)){
alert("The picture type must be one of .gif, jpeg, jpg, png")
}else{
$('both_form').action="file!upload.action";
$('both_form').submit();
$('insert_img').sethtml('

$('display_div').setstyle('display', 'block');
$ ('upload_div').setstyle('display', 'none');
}
}
Verification of image type and size
//Example 2
function validate_edit_logo(a){
var file = $('file').value;
if(!/.(gif|jpg|jpeg|png|gif|jpg|png)$/.test(file)){
alert(" The image type must be one of .gif, jpeg, jpg, png")
if(a==1){
return false;
}
}else{
var image = new image();
image.src = file;
var height = image.height;
var width = image.width;
var filesize = image.filesize;
$( 'beforeend').src=file;
$('div_regi_right').setstyle('display', 'block');
if(width>80 && height>80 && filesize>102400){
alert('Please upload an image of 80*80 pixels or less than 100k');
if(a==1){
return false;
}
}
if(a ==1){
return true;
}
}
}
Picture preview
//Example 3
function viewimg(index) {
var name = 'uploadimg' index;
var imgup = $(name);
var imgpath = getpath(imgup);
var local = imgup.value;
var point = local.lastindexof(".");
//Determine the size of the uploaded file
var img = document.createelement("img");
img.src = local;
var filesize = img.filesize;
img.onload = function (){filesize=this.filesize;}
if(img.filesize>5242880){
alert("The image file is too large! ");
return false;
}
//Determine whether it is an image format
var imgname = imgup.value.substring(imgup.value.lastindexof("."), imgup.value. length);
imgname = imgname.tolowercase();
if ((imgname != ".jpg") && (imgname != ".gif") && (imgname != ".jpeg") && ( imgname != ".png") && (imgname != ".bmp")) {
alert("u8bf7u9009u62e9u56feu7247u6587u4ef6uff0cu8c22u8c22!");
imgup.focus();
//Clear the value in file www.3ppt.com
imgup.select();
document.selection.clear();
} else {
//Display image
document.getelementbyid("sig_preview" index) .innerhtml = "

}
if (index >=3){
var cnt = index 1;
$("img" cnt).style. display = "";
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to implement image scrolling and thumbnail preview in Vue? In Vue projects, we often need to display a large number of pictures, and hope that users can browse and preview these pictures easily. This article will introduce how to use Vue components to implement image scrolling and thumbnail preview functions. First, we need to install and introduce the appropriate Vue library to facilitate image scrolling and thumbnail preview. In this example, we will use vue-awesome-swiper and vue-image-preview two libraries to implement

As one of the most popular short video sharing platforms in the world, Douyin has attracted hundreds of millions of users to join it. When looking at other people's wonderful works, we are often moved by some dynamic, interesting or meaningful moments in them. At this time, we can not only express our opinions and thoughts through text comments, but also express our emotions more vividly through picture comments. So, how to post picture comments on TikTok? First, open the Douyin APP and enter the video you are interested in. Next, we need to determine the operating system of the mobile phone according to the different

Apple today released Safari Technology Preview version 173, which covers some features that may be launched in Safari 17. This version is suitable for macOS Sonoma beta version and macOS Ventura system. Interested users can download it from the official website. Safari Technology Preview version 173 adds a feature flag block in settings, replacing the experimental feature in the original development menu. This section allows developers to quickly search for specific features and marks the status as "stable", "available for testing", "preview" or "developer" in different ways. The redesigned development menu makes it easier for creators to find key tools for building web pages, web apps, web content in other apps,

How to implement form image upload and preview in Vue form processing Introduction: In modern web applications, form processing is a very common requirement. One common requirement is to allow users to upload images and preview them in a form. As a front-end framework, Vue.js provides us with a wealth of tools and methods to achieve this requirement. In this article, I will show you how to implement image upload and preview functions in Vue form processing. Step 1: Define Vue components First, we need to define a Vue group

How to upload and preview images through Vue? Overview: In modern web applications, image uploading and previewing are a common requirement. Vue, as a popular JavaScript framework, provides a convenient way to achieve this function. This article will introduce how to use Vue to upload and preview images, including the design of the front-end interface and the processing of the back-end interface. Front-end interface design: First, we need to design a front-end interface to select and upload images. In Vue, we can use <i

How to implement image upload and preview in uniapp In modern social network and e-commerce applications, image upload and preview functions are very common requirements. This article will introduce how to implement the image upload and preview functions in uniapp, and give specific code examples. 1. Implementation of the image upload function In the uniapp project, you first need to add an image upload component to the page, as shown below: <template><view><im

Solution to the problem that everything cannot be displayed when previewing and printing: 1. Open the WPS Office form and click "Print Preview" in the upper left corner of the workbar area; 2. Enter the print preview page and click "Scale Ratio"; 3. In the drop-down list that appears Select the applicable ratio from "Landscape" or "Portrait".

We can update and upgrade the windows 11 system in the preview program of the windows system, but many friends have encountered the error code 0x0 when joining the preview program. This is because our system is missing part of the registry. You can re-export it. To solve it, let’s take a look at it together. How to deal with errors in the win11 preview program. Method 1: 1. If our system is not the latest version of the system, we can try to update it in the system update. Method 2: 1. The error may also be a problem with the registry. We can try to use the registry repair tool to repair it. Method three: 1. Download the win11 system directly from this site and install it. 2. After downloading, just install it according to the tutorial provided on this site.
