インストール
wget https://gist.githubusercontent.com/GitHub30/d6960b85c73e6e5f20386fa665873183/raw/upload.php
動作確認
JavaScript
var fd = new FormData()
fd.append('file', new File(['a'], 'a.txt'))
await fetch('http://localhost/upload.php', {
method: 'POST',
body: fd
})
var fd = new FormData()
fd.append('file[]', new File(['b'], 'b.txt'))
fd.append('file[]', new File(['c'], 'c.txt'))
await fetch('http://localhost/upload.php', {
method: 'POST',
body: fd
})
await fetch('http://localhost/upload.php?name=hoge.txt', {
method: 'POST',
body: 'hoge'
})
await fetch('http://localhost/upload.php', {
method: 'PUT',
body: 'fuga'
})
コマンドライン
curl -T image.png http://localhost/upload.php?name=image.png
curl -F file='@image.png' http://localhost/upload.php
curl -F file='@image.png' http://localhost/upload.php?folder=foo
curl -F file='@image.png' http://localhost/upload.php?folder
# For Windows
curl.exe -T image.png http://localhost/upload.php?name=image.png
curl.exe -F file='@image.png' http://localhost/upload.php
curl.exe -F file='@image.png' http://localhost/upload.php?folder=foo
curl.exe -F file='@image.png' http://localhost/upload.php?folder
# or
del alias:curl
curl -T image.png http://localhost/upload.php?name=image.png
curl -F file='@image.png' http://localhost/upload.php
curl -F file='@image.png' http://localhost/upload.php?folder=foo
curl -F file='@image.png' http://localhost/upload.php?folder
# or
curl http://localhost/upload.php?name=image.png -Method POST -InFile image.png -ContentType image/png
Add-Type -AssemblyName System.Web
curl http://localhost/upload.php?name=image.png -Method POST -InFile image.png -ContentType ([System.Web.MimeMapping]::GetMimeMapping("image.png"))
ディレクトリ内のファイル一覧を表示
echo 'Options +Indexes' > .htaccess
デモ
See the Pen upload.php by John Doe (@04) on CodePen.
JavaScript
var fd = new FormData()
fd.append('file', new File(['a'], 'a.txt'))
await fetch('https://kix51.000webhostapp.com/upload.php', {
method: 'POST',
body: fd
})
var fd = new FormData()
fd.append('file[]', new File(['b'], 'b.txt'))
fd.append('file[]', new File(['c'], 'c.txt'))
await fetch('https://kix51.000webhostapp.com/upload.php', {
method: 'POST',
body: fd
})
await fetch('https://kix51.000webhostapp.com/upload.php?name=hoge.txt', {
method: 'POST',
body: 'hoge'
})
await fetch('https://kix51.000webhostapp.com/upload.php', {
method: 'POST',
body: 'fuga'
})
コマンドライン
curl -T image.png https://kix51.000webhostapp.com/upload.php?name=image.png
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder=foo
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder
# For Windows
curl.exe -T image.png https://kix51.000webhostapp.com/upload.php?name=image.png
curl.exe -F file='@image.png' https://kix51.000webhostapp.com/upload.php
curl.exe -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder=foo
curl.exe -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder
# or
del alias:curl
curl -T image.png https://kix51.000webhostapp.com/upload.php?name=image.png
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder=foo
curl -F file='@image.png' https://kix51.000webhostapp.com/upload.php?folder
# or
curl https://kix51.000webhostapp.com/upload.php?name=image.png -Method POST -InFile image.png -ContentType image/png
Add-Type -AssemblyName System.Web
curl https://kix51.000webhostapp.com/upload.php?name=image.png -Method POST -InFile image.png -ContentType ([System.Web.MimeMapping]::GetMimeMapping("image.png"))