I am trying to post a file using cURL and receive it on the other side via a CGI Bash script and store it with the same name. After upload is completed, diff
between the original file and reconstructed one should return zero.
The way cURL sends data:
curl --request POST --data-binary "@dummy.dat" 127.0.0.1/cgi-bin/upload-rpm
Receiver script:
#!/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
echo "<p>Size=$CONTENT_LENGTH</p>"
while read -n 1 byte -t 3; do echo -n -e "$byte" >> ./foo.dat ; done
fi
fi
echo '</body>'
echo '</html>'
exit 0
But it's not working. File is not created on the server side. And how can I get the file name?