Ubuntu Curl upload file to apache2 servertable of Contents
- 1. Install
- 2. Get Web Info
- 3. Set PHP upload conditions
- 3.1. Ref
- 3.2. Upload_max_fileszie
- 3.3. Post_max_size
- 3.4. Max_execution_time CFG
- 3.5. Restart after CFG
- 4. config Upload directory
- 5. Write sup.php (store in/var/www/html)
- 6. Upload by using the curl in shell
1Install
$ sudo apt-get install apache2$ sudo apt-get install php5$ sudo apt-get install libapache2-mod-php5$ sudo apt-get install Php5-gd
2Get Web Info
$ cat/etc/apache2/sites-enabled/000-default.conf
3Set PHP upload conditions3.1Ref
http://php.net/manual/zh/features.file-upload.common-pitfalls.php
3.2Upload_max_fileszie
$ sudo nano/etc/php5/apache2/php.ini
Change ' Upload_max_fileszie = 2M ' as Upload_max_fileszie = 30M
3.3Post_max_size
$ sudo nano/etc/php5/apache2/php.ini
Change ' post_max_size = 8M ' as Post_max_size = 30M
3.4Max_execution_time CFG
$ sudo nano/etc/php5/apache2/php.ini
Change ' Max_execution_time = ' as Max_execution_time = 300
3.5Restart after CFG
$ sudo/etc/init.d/apache2 Restart
4Config upload directory
$ cd/var/www$ sudo mkdir uploads$ sudo chmod-r a+w uploads
5Write sup.php (store in/var/www/html)
Contents as below:
<?php$uploaddir = '/var/www/uploads/'; $uploadfile = $uploaddir. basename ($_files[' xx_upload ' [' name ']), if (Is_uploaded_file ($_files[' xx_upload ' [' tmp_name '])) { echo "file". $_files[' xx_upload ' [' Name ']. "Uploaed ok.\n"; if (file_exists ($uploadfile)) { echo "file exist.\n"; } else { if (move_uploaded_file ($_files[' xx_upload '] [' tmp_name '], $uploadfile)) { echo "file process ok.\n"; } }} else { echo "Possible file Upload attack!\n"; Print_r ($_files);}? >
6Upload by using the curl in shell
curl-f [Email Protected]/home/user_name/a.mp4 http://server_ip/sup.php
Attention: ' xx_upload ' is used in ' sup.php ', as the first index of ' _files '
Ubuntu Curl upload file to Apache2 server