Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Re: How can I write a file to a web server?
| Subject: | Re: How can I write a file to a web server? |
| Posted by: | "Michael Stieler" (michael.stiel..@rie.eu) |
| Date: | Thu, 24 Jan 2008 17:36:21 |
Col schrieb:
> I want to create and write to a file or append to an existing file on a web
> server. How do I do this. Are there any examples that I can look at. I found
> I could read a file using InternetReadFile, but could not write using
> InternetWriteFile.
>
> regards
>
> Col
>
>
You will need a webserver that allows this. Usually you would implement
a backend (could be a PHP script). Then you do a HTTP POST request from
your program and encode the file data into the POST paramaters. The PHP
script can then write the data to a file or append it.
Another way to transfer the file to the webserver (but you'll have to
configure it for this to work) is an HTTP PUT request. A sample PHP file
would look like this:
<?php
/* PUT data is in stdin stream */
$putdata = fopen("php://stdin","r");
/* Open a file for writing */
$fp = fopen("myputfile.ext","w");
/* Read and write a kilobyte */
while ($data = fread($putdata,1024))
fwrite($fp,$data);
/* Close the streams */
fclose($fp);
fclose($putdata);
?>
[Translated from german,
http://phpcenter.de/de-html-manual/features.file-upload.put-method.html ]
Hope this helps,
Michael Stieler
none