• ubuntu curl upload file to apache2 server


    ubuntu curl upload file to apache2 server

    1 install

    $ sudo apt-get install apache2
    $ sudo apt-get install php5
    $ sudo apt-get install libapache2-mod-php5
    $ sudo apt-get install php5-gd
    

    2 get web info

    $ cat /etc/apache2/sites-enabled/000-default.conf
    

    3 set php upload conditions

     

    3.2 upload_max_fileszie

    $ sudo nano /etc/php5/apache2/php.ini
    

    change `upload_max_fileszie = 2M' as upload_max_fileszie = 30M

    3.3 post_max_size

    $ sudo nano /etc/php5/apache2/php.ini
    

    change `post_max_size = 8M' as post_max_size = 30M

    3.4 max_execution_time cfg

    $ sudo nano /etc/php5/apache2/php.ini
    

    change `max_execution_time = 30' as max_execution_time = 300

    3.5 restart after cfg

    $ sudo /etc/init.d/apache2 restart
    

    4 config upload directory

    $ cd /var/www
    $ sudo mkdir uploads
    $ sudo chmod -R a+w uploads
    

    5 write 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.
    ";
    
        if (file_exists($uploadfile)) {
            echo "file exist.
    ";
        }
        else {
            if (move_uploaded_file($_FILES['xx_upload']['tmp_name'], $uploadfile)) {
                echo "File process ok.
    ";      
            }
        }
    }
    else {
        echo "Possible file upload attack!
    ";
        print_r($_FILES);
    }
    
    ?>
    

    6 upload by using curl in shell

    curl -F xx_upload=@/home/user_name/a.mp4 http://server_ip/sup.php
    

    Attention: `xx_upload' is used in `sup.php', as the first index of `_FILES'

  • 相关阅读:
    【Python】自己写日志功能
    shell 笔记
    python 字典,字典嵌套,字典遍历
    python基础 循环,列表,切片,列表增删改查
    Dva_react使用问题总结
    ts_react_test报错解决方法
    如何写好项目规划和方案设计文档 (转)
    script标签引入react环境三个必须cdn文件
    react点击事件对象( react封装过后事件对象 )
    react简书笔记一 环境, git 和 项目 关联
  • 原文地址:https://www.cnblogs.com/aqing1987/p/5012825.html
Copyright © 2020-2023  润新知