if (hasError == true || hasError == "true") {
if ($("#editFilePhotosExpense").val() != "") {
var name2 = $('#editFilePhotosExpense').val();
name2 = name2.replace("C:\\fakepath\\", "");
var fileInput = $("#editFilePhotosExpense")[0];
try {
var fileSize = 0;
//for IE
if ($.browser.msie) {
//before making an object of ActiveXObject,
//please make sure ActiveX is enabled in your IE browser
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var filePath = $("#editFilePhotosExpense")[0].value;
var objFile = objFSO.getFile(filePath);
fileSize = objFile.size;
//size in kb fileSize = fileSize / 1048576; //size in mb
}
else {
fileSize = fileInput.files[0].size;
}
}
catch (err1) {
alert('Tools -> Internet Options -> choose the Security tab Click the Custom Level button Enable the following settings: Run ActiveX controls and plug-ins Initialize and script ActiveX controls not marked as safe and Include local directory path when uploading file to server.');
return false;
}
if (fileSize > '25600000') {
PhotoActivity.GetPhoto();
commonNotification.AlertMessage("File exceeds 25MB.");
return false;
}
// below code is for IE 8 as it fetch the full address of file.
var indexof = name2.lastIndexOf('\\');
var fileName = '';
if (indexof != -1) {
name2 = name2.substring(indexof + 1, name2.length)
}
var name1 = name2.replace(/ /g, "-");
var name = name1.replace(/_/g, "-");
var Time = new Date();
Time = Time.getHours() + Time.getMinutes() + Time.getSeconds() + "_";
PhotoActivity.ImagePath = ProjectActivityLog.MainOnwerId + '/' + name;
PhotoActivity.ImageTitle = $('#edittitleActivity').val();
PhotoActivity.PhotoImageEditPath = "";
PhotoActivity.ActivityPhotoId = $('#editid').val();
if ($('#editcheckbox').is(':checked')) {
PhotoActivity.IsProfile = "Yes";
}
else {
PhotoActivity.IsProfile = "No";
}
var ext = '';
if (PhotoActivity.IsProfile == "No") {
ext = name.split('.').pop().toLowerCase();
if ($.inArray(ext, ["bmp", "dds", "gif", "jpg", "png", "psd", "pspimage", "tga", "thm", "tif", "tiff", "yuv"]) != -1) {
commonNotification.AlertMessage('Invalid Extension!');
return false;
}
}
else {
ext = name.split('.').pop().toLowerCase();
if ($.inArray(ext, ["doc", "docx", "log", "msg", "odt", "pages", "rtf", "tex", "txt", "wpd", "wps", "xlsx", "pdf", "zip"]) != -1) {
commonNotification.AlertMessage('Invalid Extension!');
return false;
}
}
PhotoActivity.SavePhoto();
}
else {
if ($('#editcheckbox').is(':checked')) {
PhotoActivity.IsProfile = "Yes";
}
else {
PhotoActivity.IsProfile = "No";
}
PhotoActivity.ActivityPhotoId = $('#editid').val();
PhotoActivity.ImageTitle = $('#edittitleActivity').val();
PhotoActivity.ImagePath = "";
PhotoActivity.PhotoImageEditPath = PhotoActivity.EditPath;
PhotoActivity.UpdatePhoto();
}
}
if ($("#editFilePhotosExpense").val() != "") {
var name2 = $('#editFilePhotosExpense').val();
name2 = name2.replace("C:\\fakepath\\", "");
var fileInput = $("#editFilePhotosExpense")[0];
try {
var fileSize = 0;
//for IE
if ($.browser.msie) {
//before making an object of ActiveXObject,
//please make sure ActiveX is enabled in your IE browser
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var filePath = $("#editFilePhotosExpense")[0].value;
var objFile = objFSO.getFile(filePath);
fileSize = objFile.size;
//size in kb fileSize = fileSize / 1048576; //size in mb
}
else {
fileSize = fileInput.files[0].size;
}
}
catch (err1) {
alert('Tools -> Internet Options -> choose the Security tab Click the Custom Level button Enable the following settings: Run ActiveX controls and plug-ins Initialize and script ActiveX controls not marked as safe and Include local directory path when uploading file to server.');
return false;
}
if (fileSize > '25600000') {
PhotoActivity.GetPhoto();
commonNotification.AlertMessage("File exceeds 25MB.");
return false;
}
// below code is for IE 8 as it fetch the full address of file.
var indexof = name2.lastIndexOf('\\');
var fileName = '';
if (indexof != -1) {
name2 = name2.substring(indexof + 1, name2.length)
}
var name1 = name2.replace(/ /g, "-");
var name = name1.replace(/_/g, "-");
var Time = new Date();
Time = Time.getHours() + Time.getMinutes() + Time.getSeconds() + "_";
PhotoActivity.ImagePath = ProjectActivityLog.MainOnwerId + '/' + name;
PhotoActivity.ImageTitle = $('#edittitleActivity').val();
PhotoActivity.PhotoImageEditPath = "";
PhotoActivity.ActivityPhotoId = $('#editid').val();
if ($('#editcheckbox').is(':checked')) {
PhotoActivity.IsProfile = "Yes";
}
else {
PhotoActivity.IsProfile = "No";
}
var ext = '';
if (PhotoActivity.IsProfile == "No") {
ext = name.split('.').pop().toLowerCase();
if ($.inArray(ext, ["bmp", "dds", "gif", "jpg", "png", "psd", "pspimage", "tga", "thm", "tif", "tiff", "yuv"]) != -1) {
commonNotification.AlertMessage('Invalid Extension!');
return false;
}
}
else {
ext = name.split('.').pop().toLowerCase();
if ($.inArray(ext, ["doc", "docx", "log", "msg", "odt", "pages", "rtf", "tex", "txt", "wpd", "wps", "xlsx", "pdf", "zip"]) != -1) {
commonNotification.AlertMessage('Invalid Extension!');
return false;
}
}
PhotoActivity.SavePhoto();
}
else {
if ($('#editcheckbox').is(':checked')) {
PhotoActivity.IsProfile = "Yes";
}
else {
PhotoActivity.IsProfile = "No";
}
PhotoActivity.ActivityPhotoId = $('#editid').val();
PhotoActivity.ImageTitle = $('#edittitleActivity').val();
PhotoActivity.ImagePath = "";
PhotoActivity.PhotoImageEditPath = PhotoActivity.EditPath;
PhotoActivity.UpdatePhoto();
}
}
No comments:
Post a Comment