Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9E9419C51 for ; Thu, 22 Mar 2012 10:57:46 +0000 (UTC) Received: (qmail 49813 invoked by uid 500); 22 Mar 2012 10:57:43 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 49794 invoked by uid 500); 22 Mar 2012 10:57:43 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 49786 invoked by uid 99); 22 Mar 2012 10:57:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Mar 2012 10:57:43 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sharmi.chatterjee@gmail.com designates 209.85.220.173 as permitted sender) Received: from [209.85.220.173] (HELO mail-vx0-f173.google.com) (209.85.220.173) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Mar 2012 10:57:38 +0000 Received: by vcbfl11 with SMTP id fl11so2660892vcb.18 for ; Thu, 22 Mar 2012 03:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Y1hbDmBgl19jdkHVfIyRxAqfyHwWBGWZIe/lGFXnxkY=; b=lc/XGelRG5kQmqn6RHY5pl/DY0HzOKaGxQkW4Au+ncMRo/cgFWRpk0G0kFvZyavn9L beh0pXLTv6BMV17IywYFfslotgh+JhGJdnKR551i0SfuRfrQrKlQ5fvVl8HeqMqwkAFO kv3kSWT+TmmKhsVrUQ/sUAiRjVJyGrgRZsLXU3MVti7DJ0IAIcEaZuWNprpHhxxoth4m CkV/Rx0xqkd8ZNeTGAcVqaNi8pZU4ABswOFum33THnAAB9ZMSx1x2t76N7D6elpsnUai 8xqr/MYC5nfwRMcySLcxSIFBrM7znKknOvYg/QJyv1J/qbkqycfqHTcVwLdrWRlYeYbI e+SA== MIME-Version: 1.0 Received: by 10.52.34.200 with SMTP id b8mr2962841vdj.59.1332413837766; Thu, 22 Mar 2012 03:57:17 -0700 (PDT) Received: by 10.220.14.72 with HTTP; Thu, 22 Mar 2012 03:57:17 -0700 (PDT) In-Reply-To: References: <4F6AE8D6.30309@cord.dk> Date: Thu, 22 Mar 2012 16:27:17 +0530 Message-ID: From: Sharmistha Chatterjee To: users@httpd.apache.org Content-Type: multipart/alternative; boundary=20cf30780f3e7e6e7204bbd2c599 X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [users@httpd] Uploading a file using HTTp to apache web server. --20cf30780f3e7e6e7204bbd2c599 Content-Type: text/plain; charset=ISO-8859-1 After making suffiecient study I had posted the question as I didnt find anyway where there are reading a plain/text/jpeg/video data . Php is reading form data everywhere from url encoded forms. Anyways sorry for incovenience is its off the topic. Regards, Sharmistha On Thu, Mar 22, 2012 at 4:21 PM, Tom Evans wrote: > On Thu, Mar 22, 2012 at 10:39 AM, Sharmistha Chatterjee > 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. > > > > > $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@httpd.apache.org > For additional commands, e-mail: users-help@httpd.apache.org > > -- sharmistha --20cf30780f3e7e6e7204bbd2c599 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
After making suffiecient study I had posted the question as I didnt fi= nd anyway where there=A0are reading a plain/text/jpeg/video data . Php is r= eading form data everywhere from url encoded forms.
Anyways sorry= for incovenience is its off the topic.
=A0
Regards,
Sharmistha

On Thu, Mar 22, 2012 at 4:21 PM, Tom Evans = <tevans.uk@googlemail.com> wrote:
On Thu, Mar 22, 20= 12 at 10:39 AM, Sharmistha Chatterjee
<
sharmi.chatterjee@gmail.= com> wrote:
>
> Hi,
>
> I am trying to upload a file to apache web server . The post request i= s successful. I am getting HTTP OK
>
> Post request
>
> POST /upload.php?save-as=3Dt.txt HTTP/1.1
> Host: x.x.x.x
>
> Content-Length: 5
> Content-Type: text/plain
>
> Hello
> ---------------------------------------------------------------------<= br> > 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 s= aved in the sever.
>
> <?php
> $filename=3D "t.txt";
> $content =3D $_POST["body"]; ///?? I think there is somethin= g wrong here
> $fp =3D 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@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org




--
sharmistha<= br> --20cf30780f3e7e6e7204bbd2c599--