Re: SV: [PHP] Sending files via POST

From: Date: Thu, 01 Jan 2009 14:35:40 +0000
Subject: Re: SV: [PHP] Sending files via POST
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-285344@lists.php.net to get a copy of this message
Anders Norrbring wrote:
On Thu, Jan 1, 2009 at 02:35, Anders Norrbring <anders@norrbring.se> wrote:
I'm a bit stuck.. I'm using the PEAR http_Request to send files and
data as
HTTP POST, which is working fine if I in fact have the files on disk
on the
server. Just using the method addFile..
    Okay....
But what if the file data is only in a variable? It feels like
overkill to
first save to disk, and then read it in with addFile... The HTTP POST
I'm
looking at will need to add "files" both from disk and variables.
    .... then it's not a file, it's data held in RAM (non-TSR).
Absolutely true, but the receiving end is expecting the data as a file upload.
Are you looking to stream the file content (such as the header or initial $n bytes) from you local system to the server? If so, sorry, but you're in the wrong place.
I don't really understand what you're asking for above, but to try to explain... My server is to create a HTTP POST request to another system, with a couple of "form variables" and also 2-3 "files". Much like a manual html form will do, but with no human intervention.
Ideas are welcome..
    My idea is to ask the question: how is the "file data" getting
into the "variable"?
Well, some of the "form values" are static, like user name etc. Then one file will be static (and stored on disk as a file) and added with method 'addData' to the POST request. Another "file" is generated dynamically from data stored in a SQL database and data provided by user input from visiting my site. Of course I can store this dynamically generated data to disk, add it with 'addData' and then delete it after the request is made, but it doesn't really feel like the right thing to do. Anders.
after having a flick through the source it looks like a limitation of http request; http://pear.php.net/package/HTTP_Request/docs/latest/__filesource/fsource_HTTP_Request__HTTP_Request-1.4.4Request.php.html check lines around 600 and 900+ you'd have to set the http request yourself i thinks! (setBody) may be worth contacting they who maintain the package

« previous php.general (#285344) next »