note 9797 deleted from features.file-upload by jimw

From: Date: Wed, 02 Jan 2002 00:23:00 +0000
Subject: note 9797 deleted from features.file-upload by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24049@lists.php.net to get a copy of this message
Hi, this is to upload a file manually ... For example you want to upload /home/alexander/myfile.gif to http://127.0.0.1/upload.php : <? srand((double)microtime()*1000000); $file = "/home/alexander/myfile.gif"; $content_type = "image/gif"; $content_file = join("",file($file)); $remote_page = "http://127.0.0.1/upload.php"; $boundary = "---------------------------".substr(md5(rand(0,32000)),0,10); $data = "--$boundary Content-Disposition: form-data; name=\"file\"; filename=\"$file\" Content-Type: $content_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"; $result=""; $f = fsockopen("127.0.0.1",80); fputs($f,$msg.$data); while (!feof($f) $result .= fread($f,32000); fclose($f); print $result; ?> LexZEUS

« previous php.notes (#24049) next »