"Dani CS" <co*****************@yahoo.es.quita-la-merluza> wrote in message
news:cr**********@news.ya.com...
Chung Leong wrote: "Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com> wrote in message
news:41**********************@news.sunrise.ch...
I've a page where the user may enter some values and upload some
pictures.
Unfortunately, some pictures coming from digital camera are very big,
andtake a lot of time for uploading.
I've created a DIV that I show when uploading, but this uses DHTML and
javascript, wich are not available everywhere.
How to do something like:
submit -> show upload page -> get back to article list.
My problem is that using header shows an error message, as some values
arealready sent to the browser. I want to avoid javascript.
Unfortunately you've run into a problem that no one has yet bothered to
solve: HTTP upload of large files. As far as I'm aware, a request must
arrive in its entirety at the server before the server can send
something back to the client. When you have a very large request, that means a
long long time.
This is true for PHP, but there's a guy who has implemented a progress
bar for HTTP uploads using Perl: <http://www.raditha.com/php/progress.php>
Hmmm, interesting. I've mistakenly thought that the limitation fundamental
to the HTTP protocol. Come to think of it, there is no reason why the server
can't send data to the client while it's receiving data, as the two ends of
a socket connection aren't tied to each other. It can't be done using CGI
though, at least with Apache, as mod_cgi doesn't read from stdout until the
program has read everything from stdin.
As I understand it, the Perl upload works by using one script to save the
content to a file, and another to check current file size and report it back
to the client. Javascript is used to continually refresh the latter. Not
terribly elegant but works.
Would be fairly simple to implement the same functionality with a PHP CGI.
To do this, you would write a CGI script that points to the CLI version of
the PHP executable. As it knows nothing about HTTP, no attempt would be made
to decode the incoming stream. The script itself will process the data by
reading from stdin. Deciphering RFC-1867 data isn't easy, but there's a
shortcut--the script can simply store up the request body, then post that to
another a PHP script via an internal request or pass it to the CGI PHP.
I wonder if this solution can be implement without Javascript. The basic
problem is that one submit cannot affect two windows. Somehow you have to
trigger that second, monitoring window. I suppose we can get around that by
having the window there already, in a little iframe on the page. But then
how do you make it refresh itself without Javascript?