Purging incomplete documentation of BCHS uploading script
2022-12-11
what's BCHS? and why? too much of time in hand and willingness to self harm (-_-
This is archived post - work in progress
Last week I was asked by my friend how I'm uploading photos from phone to this server, it was bit of not soo user friendly process. I tather phone + pc together and run ftp server on phone so I could connect and download with pc then scp to the public directory here. Since I have moved out of my den very recently I'm meeting new people; having interaction, sharing things and it has reached a point I'm finding it troublesome of this repitative upload cycle.
In the past, I came across a cgi script having a web form wrapper to upload documents. It was from a user on tilde.institute. I should have stolen the script that time!
location "/cgi/*.cgi" {
root "/htdocs/cgi/"
request strip 1
fastcgi {
param SCRIPT_FILENAME "/htdocs/cgi/test.cgi"
}
}
location "/cin/*" {
root "/htdocs/cin/"
request strip 1
directory auto index
}
test.cgi
#!/bin/sh
file=/tmp/m_final
cat > $file
filename1=$(head -2 $file | sed 's/^.*filename=//' | sed 's/\"//g' | sed 's/.$//' | tail -1)
lines=$(($(wc -l < $file)))
head -n $((lines - 1)) $file | tail -n $((lines - 5)) > /htdocs/dump_displ/$filename1
cat <<EOF
<h1>Upload Successful https://displ.nl/pub_listing/$filename1</h1>
EOF
exit 0
index.html
<html><head><title>Test Form</title></head>
<body>
<form action="../cgi/test.cgi" enctype="multipart/form-data" method="post">
<label class="custom-uploader" for="file">Upload Your File</label>
<input id="file" accept="image/jpeg,image/gif,image/png,application/pdf,image/x-eps" name="fileToUpload" type="file" />
<button class="btn btn-success" name="submit" type="submit"> Upload File </button>
</form>
</body>
</html>