Re: How to "download" a multi-part file at the "server" side?
| From: | Bastien | Date: | Sat, 02 Nov 2013 20:08:03 +0000 |
| Subject: | Re: How to "download" a multi-part file at the "server" side? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322412@lists.php.net to get a copy of this message | ||
Thanks,
Bastien
> On Nov 2, 2013, at 1:30 PM, Ajay Garg <ajaygargnsit@gmail.com> wrote:
>
> Hi Aziz.
> Thanks for the reply.
>
> Unfortunately, making the change suggested by you does not make any
> difference :(
>
>
> Sorry, Thanks and Regards
>
>
>> On Sat, Nov 2, 2013 at 10:51 PM, Aziz Saleh <azizsaleh@gmail.com> wrote:
>>
>>
>>
>>
>>> On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg <ajaygargnsit@gmail.com> 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"],
Try
If(move_uploaded_file($_FILES["userfile"]["tmp_name"], $filename){
Echo "file moves";
}else{
Echo "file doesn't move";
}
Also check the target directory permissions for writing
>>> $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@gmail.com> 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@mckenzies.net
>>>> 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@gmail.com>
>>> 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.
>
>
> Ajay