On Wed, Nov 09, 2005 at 08:23:04PM -0800, kumar kumar wrote: > 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 > .... > > $getdata = fopen("php://input", "r"); > ... > > while (strlen($data = fread($getdata,8192)) > 0) { > fwrite($fp,$data); > } > ... > > 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). This is a 2 part question with a 4 part answer. First, it works for large files but not for files less than 7MB. This is because php will automatically read the stdin for you base on your php ini settings: max_post_size max_upload_size Second, even if you increase that size, sometimes there is a limit on how much data can be sent to the webserver, but usually you will get a error response before the upload actually happens in most cases. Third, php by default has a time limit on how long it is going to run. By default it is 30 seconds, you can use the set_time_limit() to adjust as needed. Also, there is also timeout that can occur within the webserver as well. If for some reason there is a lag in the connection, the webserver will just assume the client is AWOL and drop the connection. I'd hate to see this happen at 89MB transfer point. Fourth, as why the 90MB file ends up being 60MB, your loop is all wrong: while (strlen($data = fread($getdata,8192)) > 0) { You are making a big mistake by assuming what strlen() of the fread should be, you should loop based on when it hasn't reach end of file: while(! feof($getdata) ) { $data = fread($getdata, 8192); ... } With those 4 points being made I do wonder why you havn't used any of the other already existing transfer methods, like ftp or sftp. It seems like a lot of work your trying to do over http, a protocol that wasn't really designed for large file transfers. Curt. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php