Just out of curiosity, before I get elbows-deep in this, has anyone does
this already, before I start rewriting the wheel? Using PHP to POST a file
and a few variables to another server's catcher script that is.

> > fputs($fp, "Content-Type: multipart/form-data; boundary=AaB03x\n");
> > fputs($fp, "--AaB03x\n");

> That looks quite reasonable

Thanks Richard.

Reasonable. I'll take that. It's better than "WHAT ARE YOU SMOKING YOU

> It's *POSSIBLE* that "Aa03x" will be *IN* the document...

Well yes, the only reason I happened to use that particular sentinel was
that I cut-n-pasted the header information. But you're right, a longer, more
complex sentinel would help.

> $myfile = file('/full/path/to/myFile.xml') or die("Could not open
> myFile.xml");
> $myfile = implode('', $myfile);
> $boundary = md5(uniqid(''));
> # Hey, the odds are one in a zillion, but why not?
> while (strstr($myfile, $boundary)){
>   $boundary = md5(uniqid(''));
> }

Ok, had to look that one up :)

uniqid is a new one on me. I've been naming files according to the session
id to prevent overwrites.

> And I think you need a different boundary for *EACH* part of
> the multipart stuff...  But maybe that's just me thinking
> wrongly...

If I understand HTTP 1.0, and I probably don't, you only need to use
seperate identifiers if you're appending more than one file, then you need a
new identifier to delineate the parts of the "FILES" section.

<HTTP Headers>
                <file header>
                        <boundary 2>
                                <file 1>
                        <boundary 2>
                                <file 2>

Not 100% accurate because I just wrote that off the top of my head, but
that's pretty much how I understand it. Anyone who knows better is free to
slap me with a trout.

> Other than that, I'm guessing that you *MIGHT* need to
> somehow "escape" the contents of the data...

I was thinking about that. I'm wondering if I can fake CRLF by sending the
ASCII equivalents.

> I dunno if browsers and web-servers expect that data to be
> uuencoded, or base64 encoded

Well, browsers don't matter, since this will all be entirely handled by the
servers. But it's definitely something to consider while I'm dorking around.

> But you're definitely on the right track, and you're down to
> minutia at this point.

Well, considering I didn't get pushed around by the big kids and have my
lunch money taken, I'll assume that I'm not totally dum. I'm guessing what I
should do now is write an upload script and try to simulate the pass and see
how close I am.

Still, I can't imagine I'm the first person trying to do a text file
server-to-server POST. It'd be nice if I could find someone who's already
done something like this. I've been Googling for it the last two days and
have found several people on Usenet and the mailing lists asking about
POSTing XML files to scripts, but nobody who said, "I did it, here's how
it's done."

Thanks again Richard.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to