PHP Classes

File: WIAdmin/WICore/WIJ/WIUpload_file.js

Recommend this page to a friend!
  Classes of Jules Warner   WICMS   WIAdmin/WICore/WIJ/WIUpload_file.js   Download  
File: WIAdmin/WICore/WIJ/WIUpload_file.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: WICMS
Database driven content management system with PDO
Author: By
Last change:
Date: 7 years ago
Size: 1,778 bytes
 

Contents

Class file image Download
$(document).ready(function (event) { $("#wiupload").on('submit',(function(event) { event.preventDefault(); alert('click'); $("#message").empty(); $('#loading').show(); $.ajax({ url: "WICore/WIClass/WIAjax.php", // Url to which the request is send type: "POST", // Type of request to be send, called as method data: { action : header_upload, upload : new FormData(this) }, // Data sent to server, a set of key/value pairs (i.e. form fields and values) contentType: false, // The content type used when sending data to the server. cache: false, // To unable request pages to be cached processData:false, // To send DOMDocument or non processed data file it is set to false success: function(data) // A function to be called if request succeeds { $('#loading').hide(); $("#message").html(data); } }); })); // Function to preview image after validation $(function() { $("#file").change(function(event) { $("#message").empty(); // To remove the previous error message var file = this.files[0]; var imagefile = file.type; var match= ["image/jpeg","image/png","image/jpg"]; if(!((imagefile==match[0]) || (imagefile==match[1]) || (imagefile==match[2]))) { $('#previewing').attr('src','noimage.png'); $("#message").html("<p id='error'>Please Select A valid Image File</p>"+"<h4>Note</h4>"+"<span id='error_message'>Only jpeg, jpg and png Images type allowed</span>"); return false; } else { var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); } }); }); function imageIsLoaded(e) { $("#file").css("color","green"); $('#image_preview').css("display", "block"); $('#previewing').attr('src', e.target.result); $('#previewing').attr('width', '250px'); $('#previewing').attr('height', '230px'); }; });