file stream reading

From: Date: Sat, 05 Nov 2005 12:41:43 +0000
Subject: file stream reading
Groups: php.windows 
Request: Send a blank email to php-windows+get-26462@lists.php.net to get a copy of this message
hi The code is written to recive the files sended by the applet thru http in streams. PHP at server side has to receive the stream using (php://input) and as to write at server file system this code is not working properly will any body pls help me in rectifying the error for all files i am receiving zero bytes Here is the code <?php $save_path = $_REQUEST['DATADIR']; $filepath = $_REQUEST['FILEPATH']; $filename = $_REQUEST['FILENAME']; $fname = "$filepath$filename"; $tdir =$save_path.$filepath; mkMDir($tdir); function mkMDir($dir,$dirmode=0777) { if (!empty($dir)) { if (!file_exists($dir)) { preg_match_all('/([^\/]*)\/?/i', $dir,$tmp); $default=""; foreach ($tmp[0] as $key=>$val) { $default=$default.$val; if(!file_exists($default)) if (!mkdir($default,$dirmode)) { return -1; } } } else if (!is_dir($dir)) { return -2; } } return 0; } $getdata = fopen("php://input","r"); $path ="$save_path" . dirname($fname); $fname = $save_path . $fname; if(isset($offset) && $offset > 0 && $offset <= filesize($fname)) { $fp = fopen($fname,"a+"); fseek($fp,$offset); } else{ $fp = fopen($fname,"wb"); } while (!feof($gettdata)) { $data = fread($getdata,1024); fwrite($fp,$data); } fclose($fp); fclose($putdata); ?> Thanking You With Regards Kumar __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com

« previous php.windows (#26462) next »