Re: file stream reading

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

 



Maybe what your using to send data is not actually sending data. Can you show us what your using to send data, please?

Thanks

Tryst

-----Original Message-----
From: kumar kumar <ripples_it@xxxxxxxxx>
To: php-windows@xxxxxxxxxxxxx
Sent: Sat, 5 Nov 2005 04:41:43 -0800 (PST)
Subject:  file stream reading

 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

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


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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux