Uploads in cgi

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Wed Apr 25, 2007 12:06 am    Post subject: Uploads in cgi Reply with quote

I'm using a seperate language (one meant for applications, not originally meant for web stuff) to use CGI.

So far, I can echo, retrieve post, get, and cookies, handle forms, all the basics.

Now, using the standard CGI protocol, how can I get what is needed to upload files?

Using this html:
Code:
<form enctype="multipart/form-data" action="upload.auw" method="POST"> Please choose a file: <input name="uploaded" type="file" />
  <input type="submit" value="Upload" /> </form>


how is it possible with cgi? in php, you use the $_FILES variable. How do I retrieve that same data?
_________________
hellooooooooo!
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed Apr 25, 2007 4:40 am    Post subject: Reply with quote

Maybe if you tell us what new language you're using, we can know the syntax so that we may help you.
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Apr 25, 2007 6:25 pm    Post subject: Re: Uploads in cgi Reply with quote

theguy0000,

What that language? Are you coding CGI stuff by hand without using a library?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Wed Apr 25, 2007 11:37 pm    Post subject: Re: Uploads in cgi Reply with quote

aprelium wrote:
theguy0000,

What that language? Are you coding CGI stuff by hand without using a library?


I have created a library. The language is called AutoIt.

Here is a link to the library I am currently using:
http://www.autoitscript.com/forum/index.php?showtopic=30564
(it's that scrollable block of code in the first post)
_________________
hellooooooooo!
Back to top View user's profile Send private message
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Fri May 04, 2007 5:03 am    Post subject: Reply with quote

uh, hello?
_________________
hellooooooooo!
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri May 04, 2007 11:36 pm    Post subject: Reply with quote

theguy0000,

Sorry for the delay to get back to you. We recommend reading RFC 1867 ( http://www.ietf.org/rfc/rfc1867.txt ) which is the official standard related to the file uploads protocol.

In CGI, the uploaded payload will be available by reading CONTENT_LENGTH bytes from the standard input. You'll have then to decode the read data according to the RFC 1867 guidelines (split them in several chunks around the boundaries, decode the headers of each chunk, and get the file data out of it).

If you need more technical details, please do not hesitate to send us your questions.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Sat May 05, 2007 1:58 pm    Post subject: Reply with quote

aprelium wrote:
theguy0000,

Sorry for the delay to get back to you. We recommend reading RFC 1867 ( http://www.ietf.org/rfc/rfc1867.txt ) which is the official standard related to the file uploads protocol.

In CGI, the uploaded payload will be available by reading CONTENT_LENGTH bytes from the standard input. You'll have then to decode the read data according to the RFC 1867 guidelines (split them in several chunks around the boundaries, decode the headers of each chunk, and get the file data out of it).

If you need more technical details, please do not hesitate to send us your questions.


Now that's the kind of answer I was looking for! :D :D

Much appreciation,
Matt
_________________
hellooooooooo!
Back to top View user's profile Send private message
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Sat May 05, 2007 3:24 pm    Post subject: Reply with quote

OK, new question.

I have created a form:
Code:
<FORM ACTION="upload.auw" ENCTYPE="multipart/form-data" METHOD=POST>
What is your name? <INPUT TYPE=TEXT NAME=submitter>
What files are you sending? <INPUT TYPE=FILE NAME=cool>
Anything else? <INPUT TYPE=FILE NAME=file>
<br />
<input type="Submit" value="GO!!!!!!!!!!!!!!!!!!!!">
</FORM>


I upload two files: hello.txt and test.txt. I get this:

Code:
-----------------------------25234242276359
Content-Disposition: form-data; name="submitter"

Matt
-----------------------------25234242276359
Content-Disposition: form-data; name="cool"; filename="hello.txt"
Content-Type: text/plain

I am a cool text file. Worship me.
And I am line two.
and line 3.....

ah! blank line!coolioum
-----------------------------25234242276359
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain

I am a cool text file. Worship me.
-----------------------------25234242276359--


My questions are these:
what is the meaning of the numbers at the end of each divider?

Why is there an extra divider at the end, that shows up when I upload text files, but not when I upload jpeg files?
_________________
hellooooooooo!
Back to top View user's profile Send private message
theguy0000
-


Joined: 25 Apr 2007
Posts: 8

PostPosted: Sat May 05, 2007 5:41 pm    Post subject: Reply with quote

Nevermind, I got it working perfectly. Thank you so much!
_________________
hellooooooooo!
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon May 07, 2007 8:56 am    Post subject: Reply with quote

theguy0000 wrote:
Nevermind, I got it working perfectly. Thank you so much!


You're welcome.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group