POST files with PHP

From: Date: Mon, 19 Nov 2001 15:44:00 +0000
Subject: POST files with PHP
Groups: php.general 
Request: Send a blank email to php-general+get-75120@lists.php.net to get a copy of this message
Hy, I'm trying to post image files to a php script with another php script. Don't ask why, it's a crazy project :) Now the file is around 28000 bytes but the post receiver only gets around 300 bytes. Has anybody experienced this behaviour? I use the following script: --- snap --- <? // the receiver of file $remote_page = "http://www.server.com/post.php"; // the file to upload $file = "/var/www/test/dummy.jpg"; // the file location $con_type = "image/jpg"; // the file mime type $content_file = join("",file($file)); // define boundary srand((double)microtime()*1000000); $boundary = "---------------------------".substr(md5(rand(0,32000)),0,10); $data = "--$boundary Content-Disposition: form-data; name=\"userfile\"; filename=\"$file\" Content-Type: $con_type $content_file"."--$boundary--\r\n\r\n"; $msg = "POST $remote_page HTTP/1.0 Content-Type: multipart/form-data; boundary=$boundary Content-Length: ".strlen($data)."\r\n\r\n"; $f = fsockopen("www.server.com",80); fputs($f,$msg.$data); $result = fread($f,32000); fclose($f); print $result."\n<br>"; ?> --- snap --

« previous php.general (#75120) next »