Git Product home page Git Product logo

cgi's Introduction

cgi's People

Contributors

kokoichi206 avatar

Stargazers

 avatar

Watchers

 avatar

cgi's Issues

movie(mp4)の保存ができない

以下の cgi に対してcurlコマンドでアップロードしようとしたが、text ファイルはアップロードできたのに、動画(ここでは mp4) はうまくいかなかった

#!/bin/bash

echo "Content-type: text/html"
echo ""

echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '<title>Foo</title>'
echo '</head>'
echo '<body>'

echo "<p>Start</p>"

if [ "$REQUEST_METHOD" = "POST" ]; then
    echo "<p>Post Method</p>"
    if [ "$CONTENT_LENGTH" -gt 0 ]; then
    in_raw=`cat`
    boundary=$(echo -n "$in_raw" | head -1 | tr -d '
');
    filename=$(echo -n "$in_raw" | grep --text --max-count=1 -oP "(?<=filename=\")[^\"]*");
    file_content=$(echo -n "$in_raw" | sed '1,/Content-Type:/d' | tail -c +3 | head --lines=-1 | head --bytes=-4  );
    echo "boundary: $boundary"
    echo "filename: $filename"
    #echo "file_content: $file_content"
    echo -en "$file_content" > /var/www/html/movie/"$filename"
    echo $?
    sudo echo /var/www/html/movie/"$filename"
    fi
fi
echo '</body>'
echo '</html>'

exit 0

使用コマンド

curl --request POST https://example.com/upload.cgi -F "[email protected]"

curl の叩き方が悪いのか、保存の仕方が悪いのか調査し、保存できるようにする

Apache Tips

ファイル場所

環境

# ハード
$ uname -a
Linux ubuntu 5.4.0-1045-raspi #49-Ubuntu SMP PREEMPT Wed Sep 29 17:49:16 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

# ソフト
# 対象 apache v
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
...

# 対象 apache v
$ apache2 -v
Server version: Apache/2.4.52 (Ubuntu)
Server built:   2021-12-28T20:18:12

ログ確認

# /var/log/apache2 がフォルダ
$ tail -f /var/log/apache2/access.log
$ tail -f /var/log/apache2/error.log

ポート

$ sudo ufw status
$ sudo ufw allow 80
$ sudo ufw deny 80
$ sudo ufw reload

設定ファイル

# フォルダ: /etc/apache2
/etc/apache2$ grep h2 -r .

# cgi
# /usr/lib/cgi-bin

# html
# /var/www/html/

apache のコマンドとか

$ systemctl restart apache2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.