Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function previewEmployeePhoto(input){
- var input = document.getElementById('employeePhoto');
- if (input.files && input.files[0]) {
- var reader = new FileReader();
- document.getElementById("emplPreview").hidden = false;
- document.getElementById("emplBr1").hidden = false;
- document.getElementById("emplBr2").hidden = false;
- document.getElementById("emplBr3").hidden = false;
- reader.onload = function (e) {
- $('#emplPreview')
- .attr('src', e.target.result)
- .width(150)
- .height(200);
- };
- reader.readAsDataURL(input.files[0]);
- }
- }
- function onRegisterEmployee(form){
- document.getElementById("registerEmployeeMessageContainer").hidden = true;
- var formData = new FormData(form);
- // console.log(form.photo.files[0]);
- formData.append("photo", form.photo.files[0]);
- $.ajax({
- type: "POST",
- url: "scripts/registerEmployee.php",
- data: formData,
- processData: false,
- contentType: false,
- success: function(data){
- document.getElementById("registerEmployeeMessageContainer").hidden = false;
- document.getElementById("registerEmployeeMessage").innerHTML = "<font color='green'>Сотрудник был успешно добавлен в систему</font>";
- console.log(data);
- },
- error: function(err){
- document.getElementById("registerEmployeeMessageContainer").hidden = false;
- document.getElementById("registerEmployeeMessage").innerHTML = "<font color='red'>Возникла ошибка. Подробности в js консоли</font>";
- console.log(data);
- }
- });
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement