Re: Uploading a file using HTTp to apache web server.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 22, 2012 at 10:39 AM, Sharmistha Chatterjee
<sharmi.chatterjee@xxxxxxxxx> 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-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux