Use the php extension module APC to upload large files

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. The installation and configuration of the APC module is Windows. You need to download the php_apc.dll file, put php_apc.dll into phpext, and add the following statement to php. ini: extensionphp_apc.dllapc.rfc18671apc.max_file_siz

Welcome to the Linux community forum and interact with 2 million technicians> go to step 1. The installation and configuration of the APC module is Windows. You need to download php_apc. dll file, and put php_apc.dll in php/ext, and in php. add the following statement to ini: extension = php_apc.dll apc. rfc1867 = 1 apc. max_file_siz

Welcome to the Linux community forum and interact with 2 million technicians>

I. Installation and configuration of APC Module

My environment is Windows. You need to download the php_apc. dll file, put php_apc.dll in php/ext, and add the following statement to php. ini:

Extension = php_apc.dll

Apc. rfc1867 = 1

Apc. max_file_size = 200 M

In addition, because you need to upload a large file, you need to change the following options in php. ini:

Upload_max_filesize = 1000 M

Post_max_size = 1000 M

Max_execution_time = 600; maximum time (in seconds) for running each PHP page. The default value is 30 seconds.

Max_input_time = 600; maximum time required for receiving data on each PHP page. The default value is 60 seconds.

Memory_limit = 128 M; maximum memory consumed by each PHP page. The default value is 8 M.

II. Get progress bar code

Getprogress. php

Session_start ();

If (isset ($ _ GET ['Progress _ key']) {

$ Status = apc_fetch ('upload _ '. $ _ GET ['ss SS _ key']);

If ($ status ['Total']! = 0 &&! Emptyempty ($ status ['Total']) {

Echo json_encode ($ status );

}

Else {

Echo (0 );

}

}

?>

Session_start ();

If (isset ($ _ GET ['Progress _ key']) {

$ Status = apc_fetch ('upload _ '. $ _ GET ['ss SS _ key']);

If ($ status ['Total']! = 0 &&! Empty ($ status ['Total']) {

Echo json_encode ($ status );

}

Else {

Echo (0 );

}

}

?>

Json is used for data transmission.

$ Status object is an array with the following fields:

Total: total file size

Current: number of files received so far

Rate: the upload speed (in bytes/s). However, it is only available after the upload is complete.

Filename: File Name

Name: variable name

Temp_filename: the location where PHP saves the temporary copy of the file

Cancel_upload: the upload has been canceled (1) or not (0)

Done: the upload has been completed (1), or has not been completed (0)

Here, we use json to upload all the data to the page for later use.

3. Main File

Upload. php

$ Id = md5 (uniqid (rand (), true ));

?>

Upload Example

"Width: 500px; height: 20px; border: 1px solid black; display: none;">

"Position: relative; height: 20px; background-color: gray; width: 0%;">


[1] [2]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.