Juicy
Juicy

Reputation: 12520

POST file with bash CGI

I'm trying to upload a file (about 30kb in this case). I'm using a bash CGI at the receiving end. So far I would just like to see the contents of the file.

Receiving end:

#!/bin/bash
echo "Content-Type: text/plain"
echo

read FILE
echo "$FILE"

Sender form:

<form class="fileup_form" method="post" action="dds_fileup.cgi" enctype="multipart/form-data">                                          
   <input type="submit" />                                              
   <input type="file" name="file" />                                    
</form> 

At the moment I get this output:

-----------------------------11054464466732224131260756282

which is definitely not the full 30kb.

Why can't I see the full contents of the POSTed file?

Upvotes: 0

Views: 3332

Answers (1)

FractalSpace
FractalSpace

Reputation: 5685

'read' only reads one line. Try this instead:

FILE=`cat`
echo $FILE

Upvotes: 1

Related Questions