C++ File Uploading

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


Joined: 20 Jun 2004
Posts: 40

PostPosted: Sun Sep 11, 2005 9:21 pm    Post subject: C++ File Uploading Reply with quote

Does Abyss Web Server break up POSTs sent by the browser over 256B in size to multiple requests?

The reason I ask is because I am trying to write a file uploading program in C++ - It works fine, on any type of file, until the file becomes larger than 256B. At that point, the program hangs and does nothing until I kill it manually. I've noticed that AWS sends data in POST requests a certain way, and was wondering if there's something going on like this:

Less-than-256B files dump output similar to this:

Quote:
-----------------------------100801427118047
Content-Disposition: form-data; name="file"; filename="Text.txt"
Content-Type: text/plain

Test

This is a test.
-----------------------------100801427118047--


So would greater-than-256b files dump output like this?

Quote:
-----------------------------100801427118047
Content-Disposition: form-data; name="file"; filename="Text.txt"
Content-Type: text/plain

(256 B of information here)
-----------------------------100801427118047--
Content-Disposition: form-data; name="file"; filename="Text.txt"
Content-Type: text/plain

(15 B additional information here)
-----------------------------100801427118047--


Thank you for any assistance.
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Sep 12, 2005 12:58 pm    Post subject: Re: C++ File Uploading Reply with quote

Lithorien,

POSTed data comes from the browser and not from the web server. In no way Abyss Web Server changes the data that is POSTed from your browser. Abyss simply forwards to the CGI process the data as it receives it from the client (browser).

There is also no 256KB limit. In PHP for example, you can upload files that are larger than that (several MB) with no problem.

By the way, what is the browser you're using to send this file? What are the HTTP headers that are sent to the CGI process?

Having your code could also help us understand the origin of the problem.

By the way, we recommend checking the specification of FILE uploads in http://www.faqs.org/rfcs/rfc1867.html .
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Lithorien
-


Joined: 20 Jun 2004
Posts: 40

PostPosted: Tue Sep 13, 2005 1:15 am    Post subject: Re: C++ File Uploading Reply with quote

aprelium wrote:
Lithorien,

POSTed data comes from the browser and not from the web server. In no way Abyss Web Server changes the data that is POSTed from your browser. Abyss simply forwards to the CGI process the data as it receives it from the client (browser).


Aha. I thought POSTed information was processed by the server and reformatted. Thanks for answering that. :)

aprelium wrote:
There is also no 256KB limit. In PHP for example, you can upload files that are larger than that (several MB) with no problem.

By the way, what is the browser you're using to send this file? What are the HTTP headers that are sent to the CGI process?


The browser is Mozilla 1.8a6. The process recieves exactly what you saw below: That quoted text is everything it gets.

aprelium wrote:
Having your code could also help us understand the origin of the problem.

By the way, we recommend checking the specification of FILE uploads in http://www.faqs.org/rfcs/rfc1867.html .


I did read the RFC that you've linked to, and here's the code so you can see what's going on:

Code:
int upload()
{
   header();

   std::string file;
   double fsize = atoi(getenv("CONTENT_LENGTH"));
   
   std::getline(std::cin, file, '\n'); // Junk
   fsize -= file.size();
   
   std::getline(std::cin, file, '\n'); // Content-Disposition: xxx; xxx; filename=
   fsize -= file.size();
   
   std::string filename = "uploads/";
   for (int x = (file.find("filename=", 0) + 10); x < (file.size() - 1); x++)
   {
      filename += file[x];
   }
   
   std::getline(std::cin, file, '\n'); // Content-Type: x/x
   fsize -= file.size();
   
   std::getline(std::cin, file, '\n'); // Blank
   fsize -= file.size();
   
   std::ofstream oFile(filename.c_str(), std::ios::binary);
      for (int x = 0; x < (fsize - 61); x++)
      {
         char *temp = new char;
         
         std::cin.read(temp, 1);
         
         std::cout.write(temp, 1);
         //oFile << file;
      }
   oFile.close();
   
   // Perform error checking for file upload here.
   
   std::cout << "File uploaded successfully to <a href=\"" << filename << "\">" << filename << "</a>";
            
   footer();
   
   return(0);
}
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Sep 13, 2005 3:20 pm    Post subject: Re: C++ File Uploading Reply with quote

Lithorien,

We'll give it a try and get back to you as soon as possible.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
cagozoe
-


Joined: 24 Apr 2005
Posts: 23

PostPosted: Wed Sep 14, 2005 2:01 am    Post subject: file upload Reply with quote

I already have a script that does file upload.

you can see it in action at:

http://www.cvb.dns2go.com/pen/upload.html

this allows any size or you can set it to a file size.

if you would like the script send me an email from our website at:

http://www.cvb.dns2go.com/gandm/email.html
Back to top View user's profile Send private message Visit poster's website
Lithorien
-


Joined: 20 Jun 2004
Posts: 40

PostPosted: Wed Sep 14, 2005 4:22 am    Post subject: Re: file upload Reply with quote

cagozoe wrote:
I already have a script that does file upload.

you can see it in action at:

http://www.cvb.dns2go.com/pen/upload.html

this allows any size or you can set it to a file size.

if you would like the script send me an email from our website at:

http://www.cvb.dns2go.com/gandm/email.html


It's not a matter of needing the script. It's a matter of learning how to do it myself.

But thank you for the offer. :)
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Mon Sep 19, 2005 1:45 pm    Post subject: Re: C++ File Uploading Reply with quote

Lithorien,

Can you please send to support@aprelium.com all your C++ code as well as your HTML form page (if any)? This will help us review the code and check what is wrong (we tried checking with the code excerpt you've sent to us but we had many problems with it).
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
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