Date : March 29 2020, 07:55 AM
should help you out ok, find the answer, just put in the following command to make it work @Command([EditGotoField]; "Control name"); @Command( [EditInsertFileAttachment] )
|
hide or show (view link ) was not working as expected when the user attach file using jquery
Date : March 29 2020, 07:55 AM
may help you . Check inline comments for detailed explanation and DEMO here$(".checkfile").on("change", function(){
var filename = this.value;
var files = this.files;
var URL = window.URL||window.webkitURL;
var url = URL.createObjectURL(files[0]);
$(this).closest('.row').find('.preview').attr("href", url).show();
//get current group's preview element using $(this) and add show in same line
document.getElementById('file_name').value = filename;
$("#file_name").prop("disabled", true);
});
//your checkbox class is not accpt_chk instead it is lbl_chk_acpt_right and so click event was not firing
$(document).on('click', ".lbl_chk_acpt_right", function () {
if ($(this).is(':checked')) {
$(this).closest('.row').find('.checkfile').attr('disabled', true);
$(this).closest('.row').find('.cst_select ').addClass("cst_select_dis");
//again get the element to disable using $(this)
} else {
$(this).closest('.row').find('.checkfile').removeAttr('disabled')
$(this).closest('.row').find('.cst_select ').removeClass("cst_select_dis");
}
});
$(document).ready(function () {
var $preview = $(".preview");
$preview.hide();
$(".checkfile").on("change", function(){
var filename = this.value;
var files = this.files;
var URL = window.URL||window.webkitURL;
var url = URL.createObjectURL(files[0]);
$(this).closest('.row').find('.preview').attr("href", url).show();
$(this).next('.check').prop("disabled", true);
var myfile = $(this).val();
var ext = myfile.split('.').pop();
if (ext == "pdf" || ext == "jpeg" || ext=="jpg") {
$(this).next('.check').val(filename);
//again get the next element of input type=file with $(this)
//$(this) refers to current element and here its .checkfile element
} else {
$(this).closest('.row').find('.preview').hide()
alert('Invalid File Type')
$(this).next('.check').val('');
e.preventDefault();
}
if(e.currentTarget.files[0].size>=1024*1024*5)
{
alert('File Size cannot be more than 5 MB')
e.preventDefault();
$(this).closest('.row').find('.preview').hide()
//hide view link here too
}
});
$(document).on('click', ".lbl_chk_acpt_right", function () {
if ($(this).is(':checked')) {
$(this).closest('.row').find('.checkfile').attr('disabled', true);
$(this).closest('.row').find('.cst_select ').addClass("cst_select_dis");
} else {
$(this).closest('.row').find('.checkfile').removeAttr('disabled')
$(this).closest('.row').find('.cst_select ').removeClass("cst_select_dis");
}
});
});
|
PHP show message based on user had attach file or not attach file (part 2)
Tag : php , By : user184975
Date : March 29 2020, 07:55 AM
should help you out Cont. on , Try like this Outside loop declare a variable $flag = 0; if(in_array($fileextension, $allowed_extensions))
{
$flag == 0 ? 0 : 1; // its image here, but check if flag is already 1,if 1, dont update else make as 0
}
else
{
$flag = 1; // error
}
if($flag) {
echo 'is not an image file';
} else {
echo 'is an image file';
}
<?php
if(isset($_POST['submit']) && ($_POST['submit'] == 'ADD'))
{
if(empty($_FILES['file1']['name']) && empty($_FILES['file2']['name']))
{
echo '2 files empty';
}
else
{
//HERE
$allowed_extensions = array('jpg','jpeg','gif','png');
foreach($_FILES as $file)
{
$name = $file['name'];
if(!empty($name))
{
$fileextension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if(in_array($fileextension, $allowed_extensions))
{
$flag == 0 ? 0 : 1; // its image here, but check if flag is already 1,if 1, dont update else make as 0
}
else
{
$flag = 1; // error
}
}
}
if($flag) {
echo 'is not an image file';
} else {
echo 'is an image file';
}
}
}
|
PHP show message based on user had attach file or not attach file (part 3)
Tag : php , By : appdelivery
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further you are using the variable before declaring and inititlizing, so keep the uploading part above like this <html>
<head></head>
<body>
<p>
<?php
if(isset($_GET['action']) && ($_GET['action'])=='add')
{
UploadFile("file1","file2");
}
function UploadFile($file1, $file2)
{
$file1Name = $_FILES[$file1]['name'];
$file2Name = $_FILES[$file2]['name'];
if(empty($file1Name) && empty($file2Name))
{
$errorMessage = 'Please upload file';
} else {
$errorMessage = '';
}
echo $errorMessage;
}
?>
</p>
<form name="addform" method="post" action="add.php?action=add" enctype="multipart/form-data">
File 1: <input type="file" name="file1" />
File 2: <input type="file" name="file2" />
<input type="submit" name="submit" value="ADD">
</form>
</body>
</html>
|
How to attach a Google Drive file in message and send through gmail API (without downloading the file)?
Tag : python , By : Moe Skeeto
Date : March 29 2020, 07:55 AM
To fix the issue you can do The problem with Google Apps is that you cannot preserve the data type when downloading or exporting them - they need to be converted to a different MIMEType. Thus, If you have problems sending e-mails with an attachment, I suggest you to do the following workaround: Include in your e-mail a link to the file, rather than the file itself. In this case you have to perform the following steps: Share the file of interest with the respective user. This is something you can do programmatically by creating and updating permissions. In your case, you need to specify emailAddress, the fileID, as well as include in the request body the role you want to give to the email recipient. In case you update an existing permission, you also need to specify the permissionId. Include the webViewLink of the desired file in your email body. You can obtain the webViewLink by listing files and specifying the webViewLink as a field you want to obtain in your response
|