I want to upload a file nearly 1GB .SO instead of HTTP i consider FTP and Socket methodlogies in PHP?
Is it possible?If possible
How can I upload a file using PHP socket?
Wh开发者_Python百科at are the advantages and disadvantages of this method over http and ftp?
Yes, It is possible to upload file using PHP.
You have to open a socket to the remote server and write to data to this socket in right format (HTTP or FTP protocol). Fortunately, CURL Lib does everything for you (see php curl for more information).
The real problem is the time limitation of program execution, PHP could not run over 5 mins (according to server's setting), so PHP could not finish pushing 1GB Data to server.
The possible solution is using CLI PHP. You could use a CGI PHP file (launched via browser) to start CLI PHP file (which does uploading)
To start CLI from CGI, use this command
exec('/usr/bin/php -f /absolute_path/to/cli_script.php > /absolute_path/to/log_file.txt &');
精彩评论