Unable to upload large file in website

Unable to upload large file in php website, here is setting for htaccess file, after this you can upload 500 mb file size, and also change this value.

php_value upload_max_filesize 5000M
php_value post_max_size 5000M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

404 redirect to homepage wordpress

if( !function_exists('redirect_404_to_homepage') ){

    add_action( 'template_redirect', 'redirect_404_to_homepage' );

    function redirect_404_to_homepage(){
       if(is_404()):
            wp_safe_redirect( home_url('/') );
            exit;
        endif;
    }
}

WordPress best performance .htaccess file content

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


#BEGIN EXPIRES HEADERS
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</IfModule>
#END EXPIRES HEADERS

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
 <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesMatch>
 <filesMatch "\.(css)$">
 Header set Cache-Control "max-age=604800, public"
 </filesMatch>
 <filesMatch "\.(js)$">
 Header set Cache-Control "max-age=216000, private"
 </filesMatch>
 <filesMatch "\.(x?html?|php)$">
 Header set Cache-Control "max-age=600, private, must-revalidate"
 </filesMatch>
</ifModule>
# END Cache-Control Headers


# ENABLE LITESPEED CACHE START
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org [NC]
RewriteCond %{REQUEST_URI} !login|admin|register|post|cron
RewriteCond %{QUERY_STRING} !nocache
RewriteRule .* - [E=Cache-Control:max-age=300]
</IfModule>
# ENABLE LITESPEED CACHE END

# START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# END ENABLE KEEP ALIVE


<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Step by step overview guide for setup business WhatsApp API

Step by step overview guide for setup business WhatsApp API with Facebook business account

What is the criteria to check my business Facebook is active for WhatsApp api

after that your WhatsApp api is fully activated.

  1. Must have Facebook business account setting
    a. WhatsApp account added into Facebook business setting
    b. Add system user
    c. Assign an App to system user via add assets
    d. Generate token for final use of WhatsApp api with selected permission
  2. Create app and add it into business Facebook account
    Note : for use WhatsApp api app type must be business

*Step by step overview guide for setup business WhatsApp API
*What is business WhatsApp API
*How to implement WhatsApp API

#1101 error in mysql / phpmyadmin

1101 – BLOB, TEXT, GEOMETRY or JSON column ‘answer’ can’t have a default value

Probably your development environment allows the defaults and the production environment doesn’t. You can either upgrade your production system or not use that feature.

How to disable strict mode in MySQL 5 (Windows):

  • Edit /my.ini and look for linesql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  • Replace it withsql_mode='MYSQL40'
  • Restart the MySQL service (assuming that it is mysql5)net stop mysql5 net start mysql5

If you have root/admin access you might be able to execute

mysql_query("SET @@global.sql_mode='MYSQL40'");

#2006 – MySQL server has gone away

MySQL/MariaDB related:

  • wait_timeout – Time in seconds that the server waits for a connection to become active before closing it.
  • interactive_timeout – Time in seconds that the server waits for an interactive connection.
  • max_allowed_packet – Maximum size in bytes of a packet or a generated/intermediate string. Set as large as the largest BLOB, in multiples of 1024.

Example of my.cnf:

[mysqld]
# 8 hours
wait_timeout = 28800
# 8 hours
interactive_timeout = 28800
max_allowed_packet = 256M

If you are using xampp server :

Go to xampp -> mysql -> bin -> my.ini

Change below parameter :

max_allowed_packet = 500M

innodb_log_file_size = 128M

send file using volley android

This is what I used to upload a PDF, but you can use it to any file. I used the same VolleyMultipartRequest, you just have to get the data from the file to upload it. Hope it helps you!

private void uploadPDF() {
    VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(
            Request.Method.POST,
            url,
            new Response.Listener<NetworkResponse>() {
                @Override
                public void onResponse(NetworkResponse response) {
                    //Handle response
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //Handle error
                }
            }
    ) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            //Params
            return params;
        }

        @Override
        protected Map<String, DataPart> getByteData() {
            Map<String, DataPart> params = new HashMap<>();
            String pdfName = String.valueOf(System.currentTimeMillis() + ".pdf");
            params.put("pdf", new DataPart(pdfName, getFileData()));
            return params;
        }
    };

    //I used this because it was sending the file twice to the server
    volleyMultipartRequest.setRetryPolicy(
            new DefaultRetryPolicy(
                    0,
                    -1,
                    DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
            )
    );

    requestQueue.add(volleyMultipartRequest);
}

private byte[] getFileData() {
    int size = (int) pdf.length();
    byte[] bytes = new byte[size];
    byte[] tmpBuff = new byte[size];

    try (FileInputStream inputStream = new FileInputStream(pdf)) {
        int read = inputStream.read(bytes, 0, size);
        if (read < size) {
            int remain = size - read;
            while (remain > 0) {
                read = inputStream.read(tmpBuff, 0, remain);
                System.arraycopy(tmpBuff, 0, bytes, size - remain, read);
                remain -= read;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return bytes;
}

5 Reasons to Invest with Paytm Money

I don’t need to Invest.

You do. Have goals? Like smart people, invest to achieve them faster.

I don’t have enough money to Invest.

You just need as little as Rs.100 to start with.

I don’t want to take a big risk.

Get a free risk assessment done on Paytm Money – Invest accordingly.

I don’t know which funds to pick.

Easy. Our experts have picked mutual funds exclusively for you in the form of investment packs.

I don’t have the financial expertise to manage

Mutual Funds are managed by financial experts, hence, you do not need to be an expert.