开发者

How to maintain a persistent http connection in php?

i've a little web interface which uploads a file on a server and then dumps that file in oracle db. but there are about 7 million records in it and web server get time out while reading and dumping that file. can someone please tell me how can i keep that session alive so that it doesn't get timeout when uploading, reading and dumping data in db?

guys, i'm talking about the time that will be taken when a user upl开发者_开发百科oads a file and it'll be dumped in db....now 7million records are enormous and the web server will definitely timeout....and if oracle times out as well, then what to do.....i know its confusing but i dont want to let user know that his file isn't dumped in db...asynchronous mechanism isn't an option in this case...i'm using apache at the moment

it is a simple script so far, few html objects and php. and i've to make it in php... =)

anticipating your valuable response. thanks


To keep script running, put this code at the begining of the php file. I think this works only if you make a direct call to the file. I mean, I don't believe works if the php file are include.

set_time_limit(0);
header('Connection: close');
ignore_user_abort();

From here: http://php.oregonstate.edu/manual/en/features.connection-handling.php

Hope this helps, Ismael.


There is no such thing as a "persistent http connection"

how can i keep that session alive

HTTP is stateless therefore session management is not implemented by the protocol - and is also nothing to do with the problem you describe.

and web server get time out

Maybe if you had told us what webserver it was then we might have been able to suggest ways of manipulating the timeout.

Also, you don't say why you think that its a timeout issue rather than something else going wrong (e.g. file size limit) and you've not discriminated between the upload and subsequent dataload as the point at which the script fails.

....but the right way to solve the problem would be to launch a seperate, independent process to carry out the dataload after the file has uploaded. Have a google for 'Long running php process setsid'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜