> fputs($fp, "Content-Type: multipart/form-data; boundary=AaB03x\n");
> fputs($fp, "--AaB03x\n");
> fputs($fp, "Content-Disposition: form-data; name="variable1"\n");
> fputs($fp, "\n");
> fputs($fp, "Variable 1 Data\n");
> fputs($fp, "--AaB03x\n");
> fputs($fp, "Content-Disposition: form-data; name="files";
>filename="myFile.xml"\n");
> fputs($fp, "Content-Type: text/plain\n");
> fputs($fp, "\n");
> fputs($fp, "... contents of myFile.xml ...\n");
> fputs($fp, "--AaB03x--\n");

That looks quite reasonable, EXCEPT:

It's *POSSIBLE* that "Aa03x" will be *IN* the document...  I'd choose a
longer and more random boundary, and maybe even be 100% sure by using
something like this:

$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(''));
}

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

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

I dunno if browsers and web-servers expect that data to be uuencoded, or
base64 encoded, or anything like that... But if they do, and you don't do
that, well, it ain't gonna work.  PHP has the functions for doing it, I just
don't know if you need them or which one...

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

-- 
Like Music?  http://l-i-e.com/artists.htm

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

Reply via email to