logo
down
shadow

PHP show message based on user had attach file or not attach file


PHP show message based on user had attach file or not attach file

Content Index :

PHP show message based on user had attach file or not attach file
Tag : php , By : fstender
Date : December 01 2020, 05:00 PM

I wish this help you Let's say I have this form: , Give the following a try:
if( !empty( $_FILES['file1']['name'] ) && !empty( $_FILES['file2']['name'] ) )

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Lotus Notes, button click attach file instead attach file from menu


Tag : development , By : George H.
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] )

Tag : javascript , By : Dominique Vocat
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
Related Posts Related QUESTIONS :
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • PHP Deployment to Live Server
  • Ideal Multi-Developer Lamp Stack?
  • How can I save an image from a file input field using PHP & MySQL?
  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in
  • Connecting to external MySQL DB from a web server not running MySQL
  • Is it possible to add custom fields to a Drupal taxonomy term?
  • PHP 6.0 - Roadmap?
  • jQuery wait for ajax call to be over before continuing
  • checkUnique function?
  • How to define an n-m relation in doctrine?
  • Sort the unsorted text file and rewrite to same text file in sorted order
  • Version control a content management system?
  • How can i run Single PHP File using apache-tomcat-6.0.18?
  • Array of objects is empty when I come to retrieve one from the array
  • PHP Library: Calculate a bounding box for a given lat/lng location
  • Good Wordpress Theme/plugin for showing off code examples and scripts
  • Replace all spaces and special symbols with dash in URL using PHP language
  • globally get any field value in user table of logged in user
  • Can you get a job if you know XHTML, CSS and Basic PHP?
  • HTML Upload Form will only upload files found in the directory of the PHP file
  • Determine if a PHP array uses keys or indices
  • Are frameworks really necessary for beginners/intermediates?
  • PHP File Downloading Questions
  • Who owns a php exec tar extracted file?
  • Best way to get timezone of user based on area code
  • Mysql BETWEEN clause being ignored. No syntax error
  • Zend Framework: Getting request object in bootstrap
  • PHP + GD: imagetruecolortopalette not keeping transparency
  • Good Guide For Web App Security?
  • Creating a new wordpress post from twitter tweets
  • Query to show images with recent posts in Wordpress sidebar/widget
  • select & print multiple value from dropdown list
  • Storing a digital signature for bookings on a web based system
  • How to generate all permutations of a string in PHP?
  • How do I get the PostgreSQL PHP extension working on Windows?
  • Parsing WordPress XML, slash:comments syntax?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com