SV: [PHP] Sending files via POST



On Thu, Jan 1, 2009 at 02:35, Anders Norrbring <anders@xxxxxxxxxxxx>
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.

.