Clear File Input Field of IE and Other Browsers Using Jquery

Because of the security restriction IE doesn’t allow to clear the file input field. IE makes it read only field. But many times i need to clear the file input field to validate in JavaScript. Here is a workaround i used to clear the file input filed in IE-

//For IE
$("#inputFile").replaceWith($("#inputFile").clone(true));

//For Firefox, Chrome, Safari and Others
$("#inputFile").val("");
Advertisements

Setting Up Apache Virtual Host In Linux Mint

I have tested it on Linux Mint to create virtual host for setting up a Zend Framework application. It should also work on Ubuntu and Debian based distro-

1. Edit the httpd.conf using the following command on terminal-

  $ sudo gedit /etc/apache2/httpd.conf

Add the following line to this file
N.B. : Replace PlayWithZend.com to your desired host name.

    <VirtualHost *:80>
        ServerName PlayWithZend.com
        DocumentRoot /var/www/playwithzend/public # application public directory
     
        SetEnv APPLICATION_ENV "development"
     
        <Directory /var/www/playwithzend/public>
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

2. Edit the httpd.conf using the following command on terminal-

  $ sudo gedit /etc/hosts

Add the following line to this file-

127.0.0.1      PlayWithZend.com  # Your Virtual host name

3. Open your terminal and write one by one –

  $ sudo a2enmod rewrite
  $ sudo updatedb
  $ cd /etc/apache2/mods-enabled
  $ touch rewrite.load
  $ sudo gedit rewrite.load

If you dont get the following line in your editor then add it-
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

4. Restart your apache-

  $ sudo /etc/init.d/apache2 restart

Open up PlayWithZend.com(your hostname here) and see the boom 😀

Installing Foxit Reader in Ubuntu 64 bit

Ubuntu comes up with many good softwares and repositories. But i missed my favorite pdf reader and editor “Foxit Reader” in ubuntu. Although the Foxit Reader support 32 bit architecture of ubuntu and they don’t have 64 bit version of installation package. To install it in your 64 bit Ubuntu –

Download the .deb package from the
http://www.foxitsoftware.com/pdf/desklinux/download.html

Open Terminal and go to the folder where you downloaded the file and use the following command-

sudo dpkg -i --force-architecture FoxitReader_1.1.0_i386.deb

Send email using PHP and your Gmail account

Using PHP’s mail() function you can't send mail using SMTP server of your choice. Because this function doesn't support SMTP Authentication.So, you can install Pear Mail Package to send email. Here i have given an example of how to send email using your Gmail account. Just make sure you installed Pear Mail Package. Run the the following code and see it works like a charm :)

<?php
 require_once "Mail.php";
 
//Your gmail address "Monika" is the name of yours. Name is optional
 $from = "Monika <your-email@gmail.com>"; //change to your email here
 $to = "Zebra <someone@ymail.com>"; //change to your receiver address
 $subject = "Hi!";
 $body = "Hi, Zebra this is a test email sent by using php";

 $host = "smtp.gmail.com";
 $port = "587";

 $username = "your-email@gmail.com"; //give your email address here
 $password = "password";  //give your password here
 
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     'auth' => true,
     'username' => $username,
     'password' => $password));
 
 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
 ?>

Software License

Getting a license allow an individual or group to use a piece of software according the agreement. Nearly all applications are licensed rather than sold. There are a variety of different types of software licenses. Some are based on the number machines on which the licensed program can run whereas others are based on the number of users that can use the program. Most personal computer software licenses allow you to run the program on only one machine and to make copies of the software only for backup purposes. Some licenses also allow you to run the program on different computers as long as you don’t use the copies simultaneously.

 

There are mainly two types of software license system –

 
  1. Proprietary License: It grants the use of one or more copies of software under the end-user license agreement (EULA), but ownership of those copies remains with the software publisher (hence use of the term “proprietary”).

    The most significant effect of this form of licensing is that, if ownership of the software remains with the software publisher, then the end-user must accept the software license. In other words, without acceptance of the license, the end-user may not use the software at all. One example of such a proprietary software license is the license for Microsoft Windows.

  2. Free & Open Source License: A free open source license makes software free for inspection of its code, modification, and distribution. Some free licenses.

Open source licenses generally fall under two categories:

  • Copyleft License: Under copyleft, an author may give every person who receives a copy of a work permission to reproduce, adapt or distribute it and require that any resulting copies or adaptations are also bound by the same licensing agreement. e.g-  GNU General Public License(GPL).
  • Permissive License: Grant the end-user permission to do anything they wish with the source code in question, including the right to take the code and use it as part of closed-source software or software released under a proprietary software license. e.g. Berkeley Software Distribution(BSD) and the MIT license.