Home > Article > Backend Development > swfupload configuration and usage_PHP tutorial
swfupload is a component used for file upload. We think it is very good for large files. Let me introduce the configuration and use of swfupload.
swfupload is easy to use for uploading large files. Let’s take the classic form demo as an example to briefly explain the usage.
Download address: http://code.google.com/p/swfupload/downloads/ list
Among them, SWFUpload_v250_beta_3_samples.zip is the example code. After decompression, rename it to swfupload and save it to the local main folder (nginx+php environment). You can then use
http://localhost /swfupload/demos/ Access two folders in
. demos is an instance of the client, and samples provides file saving codes in each language.
Switch to http://localhost/swfupload/demos/formsdemo/, which is the normal form mode
Create a new folder uploads under /demos/formsdemo/
Change /smaples Copy the code in /php/upload.php to the beginning of /demos/formsdemo/upload.php, that is,
// The Demos don't save files
below the comment.
Modify
The code is as follows | Copy code | ||||
|
代码如下 | 复制代码 |
if (isset($_FILES["resume_file"]) && is_uploaded_file($_FILES["resume_file"]["tmp_name"]) && $_FILES["resume_file"]["error"] == 0) { echo rand(1000000, 9999999); // Create a pretend file id, this might have come from a database. } |
In the database processing part, the following code should be modified:
The code is as follows | Copy code | ||||
if (isset($_FILES["resume_file"]) && is_uploaded_file($_FILES["resume_file"]["tmp_name"]) && $_FILES["resume_file"]["error"] == 0) { echo rand(1000000, 9999999); // Create a pretend file id, this might have come from a database.
|
代码如下 | 复制代码 |
view sourceprint?http { ... client_max_body_size 128M ... } |
The code is as follows | Copy code |
/demos/formsdemo/index.php in view sourceprint?file_size_limit: " 100 MB", |
The code is as follows | Copy code |
view sourceprint?http { ... client_max_body_size 128M ... } |
At the same time, you need to modify the server configuration php.ini, /etc/init.d/php-cgi reload
The code is as follows
|
Copy code
|
||||
view sourceprint?upload_max_filesize 100M |