Re: How to "download" a multi-part file at the "server" side?

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

 



On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg <ajaygargnsit@xxxxxxxxx> wrote:

> Hi all.
>
> 1.
> I could have the proper "$_FILES["userfile"]["name"]" been echoed back, by
> replacing
>                                        ContentBody cbFile = new
> FileBody(file, "image/png");
>
> with
>                                        ContentBody cbFile = new
> FileBody(file);
>
>
>
> 2.
> However, now I am stuck with the following server-side code.
> No matter what I do, I always get a "no" echoed back (specifying that the
> file is not copied to its target place).
>
>
>
> ###########################################################################
> <?php
>
> $headers = apache_request_headers();
>
> foreach ($headers as $header => $value)
> {
>         if($header == "active_window_title")
>         {
>                 $active_window_title = $value;
>                 break;
>         }
> }
>
>
> $target_path = "/home/ajay/success.png";
>
> move_uploaded_file($_FILES["userfile"]["tmp_name"], $target_path);
> if(file_exists($target_path))
> {
>         echo "yes";
> }
> else
> {
>         echo "no";
> }
>
> echo "\n" . $_FILES["userfile"]["name"];     # I always get the proper
> file-name echoed.
>
> ?>
>
> ####################################################################################
>
>
>
>
>
> Any ideas what stupidity am I making in the PHP code?
>
>
> On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg <ajaygargnsit@xxxxxxxxx> wrote:
>
> > Does not work :(
> >
> >
> > As per the code-snippet I pasted,
> >                                              $_FILES["userfile"]["name"]
> >
> > should be
> >                                                     /path/to/png/file.png
> >
> >
> > However, $_FILES["userfile"]["name"] is empty.
> >
> >
> > On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie <shawn@xxxxxxxxxxxxx
> >wrote:
> >
> >> Fairly easy:
> >> http://www.php.net/manual/en/features.file-upload.post-method.php
> >>
> >>
> >> On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg <ajaygargnsit@xxxxxxxxx>
> wrote:
> >>
> >>> Hi all.
> >>>
> >>> I intend to implement a use-case, wherein the client uploads a file in
> >>> multi-part format, and the server then stores the file in a mysql
> >>> database
> >>> (after "downloading it at the server side).
> >>>
> >>> I have been unable to find any immediate answers through googling; I
> will
> >>> be grateful if someone could start me in a direction to achieve the
> >>> "downloading at server via php" requirement.
> >>>
> >>> (Don't think it should matter, but I use Java to upload a file in
> >>> multi-part format).
> >>>
> >>> I will be grateful for some pointers.
> >>>
> >>> Thanks in advance
> >>>
> >>>
> >>> Thanks and Regards,
> >>> Ajay
> >>>
> >>
> >>
> >
> >
> > --
> > Regards,
> > Ajay
> >
>
>
>
> --
> Regards,
> Ajay
>

Ajay, try changing your mpEntity to:

new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)

See if it makes a difference.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux