Error in reading and writing bytes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
i am new to PHP .I am facing some problems .
Here is the code below

Here the applet will send the files thru http . files
from 30 bytes   to 2 GB.

<?php
		
	$logfile = "C:/temp/log1.txt";
	$log = fopen($logfile,"a+");
        
	fwrite($log, "Executing PHP Script \r\n");
        
	$save_path  = $_REQUEST['DATADIR'];
	$filepath = $_REQUEST['FILEPATH'];
	$filename = $_REQUEST['FILENAME'];
		
	$fname = "$save_path$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;
   }            

    
  $fp = fopen($fname,"w");

  $getdata = fopen("php://input", "r");

  fwrite($log, "$fname Uploaded Successfully \r\n");
				

while (strlen($data = fread($getdata,8192)) > 0) {
fwrite($fp,$data);	
}
		
	fclose($fp);
		fclose($getdata);
		fclose($log);
?>

I tried this one its working for bigger files , but
its not working for small files less than 7 MB i am
unable to track the error or reason.and some times its
writing the less amount of bytes(60MB) then the
original one(90MB).

If possible please go thru this code and suggest me
the changes.

Thanking you
With Regards
Kumar



 




		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux