Loading...

Getting star Upload Large Files in PHP

View: 442    Dowload: 0   Comment: 0   Post by: hanhga   Category: Php&mySql   Fields: Other

One of the most popular uses is image uploads. Your users can submit photographs from a form without resorting to FTP or other convoluted methods. HTML5 and Flash also permit drag and drop, so the operation is likely to become easier as browsers evolve.

This is where the problems can begin. Camera manufacturers continually brag that they have a larger set of megapixels than their competitors. It’s all rubbish, of course — unless you’re a professional photographer or need to print extremely large images, anything over 4MP is fairly pointless and lens quality is much more important. However, even low-end compacts have 12MP and mobile phones have more than 5MP. The result is that a typical snapshot can easily be 6MB in size.

By default, PHP permits a maximum file upload of 2MB. You can ask users to resize their images before uploading but let’s face it: they won’t. Fortunately, we can increase the limit when necessary.

Two PHP configuration options control the maximum upload size: upload_max_filesize andpost_max_size. Both can be set to, say, “10M” for 10 megabyte file sizes.

However, you also need to consider the time it takes to complete an upload. PHP scripts normally time-out after 30 seconds, but a 10MB file would take at least 3 minutes to upload on a healthy broadband connection (remember that upload speeds are typically five times slower than download speeds). In addition, manipulating or saving an uploaded image may also cause script time-outs. We therefore need to set PHP’s max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

These options can be set in your server’s php.ini configuration file so that they apply to all your applications. Alternatively, if you’re using Apache, you can configure the settings in your application’s.htaccess file:

php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 300
php_value max_execution_time 300

Finally, you can define the constraints within your PHP application:

ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

PHP also provides a set_time_limit() function so you don’t need to set max_execution_timedirectly.

Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large upload. Other forms would revert to the default 30-second time-out and 2MB limit.

Do you have any other tips for uploading large files in PHP?

Getting star Upload Large Files in PHP

One of the most popular uses is image uploads. Your users can submit photographs from a form without resorting to FTP or other convoluted methods. HTML5 and Flash also permit drag and drop, so the operation is likely to become easier as browsers evolve.

Posted on 23-04-2016 

Comment:

To comment you must be logged in members.

Files with category

  • PHP-University Application System

    PHP-University Application System

    View: 0    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Greeting from Malawi the warm heart of Africa. I developed this university registration system project just to share with the people who can make use of the project like this and at the same time for others like students who can learn from it. This...

  • School Event Management System in PHP/MSQLi

    School Event Management System in PHP/MSQLi

    View: 0    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    This School Event Management System can create school events such as Volleyball games, Basketball, Cultural presentation, Election of school officers etc . During school election Instead of having a compile list of candidates and voters this system...

  • Resort Reservation System with PayPal/Credit Card/Debit Card Payment

    Resort Reservation System with PayPal/Credit Card/Debit Card Payment

    View: 8    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    This reservation system has the ability to help its customers find available rooms, cottages and even function hall for their convenience . And in here, they will also have the idea of the room rates where they can quickly reserve for their family...

  • Activity log

    Activity log

    View: 9    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Simple program to track user's activity log-in time and online/offline status.

  • Electricks - eCommerce

    Electricks - eCommerce

    View: 12    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Electricks is an e-commerce website built using PHP, Bootstrap and some jQuery plugins. It has all the major functionalities of a typical e-shop. This project was used to present in Southern Luzon State University - Lucban. Feel free to use this code...

  • Simple Email App Using PHP

    Simple Email App Using PHP

    View: 7    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Creating a simple PHP script using mail function for sending out emails.

  • SUP Online Shopping

    SUP Online Shopping

    View: 104    Download: 3   Comment: 0

    Category: Php&mySql     Fields: none

    It is commonly known as electronic marketing. It consist of buying and selling goods and services over an electronic system such as the internet . E-commerce is the purchasing , selling & exchanging goods and services over computer network or...

  • Young Entrepreneur E-Negosyo System

    Young Entrepreneur E-Negosyo System

    View: 53    Download: 2   Comment: 0

    Category: Php&mySql     Fields: none

    Young Entrepreneur E-Negosyo System is a kind of online ordering system with an SMS notification. It is a convenient way for customers to purchase their favorite pastries, cakes and bread online without going to the store. With just one click they...

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd