Ubuntu Curl upload file to Apache2 server

Source: Internet
Author: User
Tags curl upload file

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

Related Article

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.