On Thu, Mar 22, 2012 at 10:39 AM, Sharmistha Chatterjee
<sharmi.chatter...@gmail.com> wrote:
>
> Hi,
>
> I am trying to upload a file to apache web server . The post request is 
> successful. I am getting HTTP OK
>
> Post request
>
> POST /upload.php?save-as=t.txt HTTP/1.1
> Host: x.x.x.x
>
> Content-Length: 5
> Content-Type: text/plain
>
> Hello
> ---------------------------------------------------------------------
> Now with the .php script upload.php I am trying to save the file as t.txt .. 
> Can anyone point me where I am going wrong the file is not getting saved in 
> the sever.
>
> <?php
> $filename= "t.txt";
> $content = $_POST["body"]; ///?? I think there is something wrong here
> $fp = fopen($filename,"a"); // $fp is now the file pointer to file $filename
> if($fp){
> fwrite($fp,$content); // Write information to the file
> fclose($fp); // Close the file
> echo $filename . " has been saved sucessfully.";
> }
> else {
> echo $filename . " was not saved successfully.";
> }
> ?>
>
>
> Regards,
> Sharmistha
>

Sharmistha

This is not particularly on-topic for the Apache mailing list. Try a
PHP list, or some books on how browsers communicate with websites.

In order to use things like $_POST in PHP, PHP must receive the post
data in a format that it can understand, which is either
'application/x-www-form-urlencoded' or 'multipart/form-data'. Your
data is not encoded into any format it can understand - it is just
'text/plain'.

You should do some reading/research on how HTTP works, rather than
bombarding this list with off topic questions. If you still have
questions after that, come back and ask them.

Cheers

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to