You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Brian Mearns <bm...@ieee.org> on 2008/12/02 13:54:44 UTC

Re: [users@httpd] File upload to Apache server without third party software

Well, It's very possible you know something I don't, but based on my
understanding on POST, it sounds like you're confused about how it
works. The use case I'm familiar with is to create a cgi script, or a
server side script like PHP that receives the POST data and saves it
to a file. And you're right, it is just like GET, the content of the
URL you specified will be returned by the server. The only difference
I know of between GET and POST is that with GET, the client sends data
encoded in the URL, and with POST, the data is included as the body of
the HTTP request.. That's why post is used for uploading files.

However---and again, this is just my understanding of it---POST is not
intended to just arbitrarily create or change files on the server, you
have to use some server side mechanism (again, a cgi or php or
something) to actually receive the POSTed data and write it to a file.

It sounds like what you may be interested in is some sort of WebDAV
method. This is an extension to the HTTP standard that's meant for
sharing files over an HTTP connection, and it has more powerful
methods than standard HTTP. I'm not sure if it has something you're
looking for, but it might be worth a look.

Hope that helps,
-Brian

-- 
Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from: https://keyserver.pgp.com


On Mon, Dec 1, 2008 at 1:09 PM,  <pr...@webdunia.com> wrote:
> Hi All,
>
> First of all, sorry for the long mail.  To give a gist of the mail, I want to know how to use the POST method for Apache server without installing Tomcat or anything.
>
> I have a "Server version: Apache/2.0.54" installed in my system.  I have configured it to act as a server as well as a proxy server; which means the Apache is working fine.
>
> Now I try to do some configuration so that the Apache server will support uploading of files (i.e. POST method).
>
> For that I created a folder "public" and the configuration in httpd.conf for the same is as follows:
>
> <Directory "/var/www/html/public">
>    AllowOverride None
>    Options None
>    <Limit POST GET HEAD DELETE>
>        Order allow,deny
>        Allow from all
>    </Limit>
> </Directory>
>
> Then "/etc/init.d/httpd restart".
>
> Then POST command is executed to create a new file "NotExists.txt" in "/var/www/html/public":
>
> User  :$> POST "http://127.0.0.1/public/NotExists.txt"
> Reply :$> Please enter content (application/x-www-form-urlencoded) to be POSTed:
> User  :$> helloooooooooooooooo
> User  :$> Ctrl D
> Reply :$> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
>          <html><head>
>          <title>404 Not Found</title>
>          </head><body>
>          <h1>Not Found</h1>
>          <p>The requested URL /public/hello.txt was not found on this server.</p>
>          <hr>
>          <address>Apache/2.0.54 (Fedora) Server at 127.0.0.1 Port 80</address>
>          </body></html>
>
> [
>  "User" is the User Input given by the user.
>  "Reply" is the reply printed out on to the terminal.
> ]
>
> And in case, the POST is done for a file which already exists in the server, the content of the file is given back (i.e., it behaves as if a GET request is sent!).
>
> Also, would like to know whether the DELETE method is supported by Apache.  If so, what should be the configuration.
>
> Regards,
> prasanth
>
>
> India's first Indian Language Mailing System,Now in a New Look and Feel.Open your FREE e-mail account today!!!
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] File upload to Apache server without third party software

Posted by André Warnier <aw...@ice-sa.com>.
Brian Mearns wrote:
[...]
Thanks Brian, I agree with what you wrote.

Prasanth, maybe the correct place to start is here :
http://www.faqs.org/rfcs/rfc2616.html

The various HTTP "methods" are described in section 9.2 and later.
I suggest to start reading from the beginning however.
The way in which Apache and some of its modules work (or any other web 
server for that matter), are only understandable when you have at least 
a basic understanding of the HTTP protocol.
By telling you that, we are trying to help you.  The questions you are 
asking, and the way you are asking them, makes us think that you are 
missing some basic parts of the puzzle.

For example, Brian mentioned WebDav.
You will find how to set it up in Apache here :
http://httpd.apache.org/docs/2.2/mod/mod_dav.html#dav
Installing Dav in Apache will allow you to send PUT requests, including 
a file to upload to your server. It will do that right out-of-the-box, 
which is what you seem to want.

But, do you notice the red box in the middle of the page ?

It tells you that unless you know exactly what you are doing, anybody 
having access to your webserver is going to be able to download any file 
from your computer, or upload any file to it.  For example, /etc/passwd.
It is much like making the C:\ directory of your PC into a network 
share, with read/write permission to Everyone.
I am quite sure you do not want that.





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org