The first is to hide the file upload input style:
<a class= "link Uploadphoto" href= "#" onclick= "Upload_file.click ()" >
<input type= "File" class= "Form-control" id= "Upload_file" name= "Upload_file" style= "Display:none;" Onchange= "Addpic ();" />
Upload photos </a>
Note: Place the INPUT element in the middle of any other element, formatted as style= "Display:none;" Hidden, while the outside element sets the onclick (onclick= "Upload_file.click ()") event,
When the outside element is clicked to trigger the click event of input, the rest is on the outside
The elements to beautify the process!
Here is the verification of the uploaded file:
function Addpic () {
var objfile = document.getElementById ("Upload_file");
Focus here, you can get the uploaded files;
var file=objfile.files[0];
var name=file.name.tolowercase ();
alert (name);
if (Name.indexof (". png") >-1 | | name.indexof (". gif") >-1
|| Name.indexof (". jpg") >-1) {
You can use Ajax for photo Echo
} else {
$.ligerdialog.warn ("Please select *png,*gif,*jpg type picture!");
}
};
The hidden file upload input style also verifies the uploaded file format