Upload files message

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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, and
take 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 are
already sent to the browser. I want to avoid javascript.

Any idea ?


Re: Upload files message

"Erwin Moller"
Quoted text here. Click to load it
Hi Erwin.

I've a "insertarticle.php" page. In this page, I can upload up to 5 images
files. As some are very big files, it takes a while. So I want to show a
progress bar (not possible with PHP but a progress list "progress.php") and
then redirect to the "managepage.php".

I'd like to show the message while the file are uploaded (with flush...)
echo('<br>start uploading'.$filename1);
//upload code here
echo('<br>upload successfull'.$filename1);
then redirect to the page "managepage.php"

since I send datas to the "progress.php" page and I want to avoid using
javascript (as some people don't allow javascript), I even can't use

It's there any other way to redirect ? I may create a button for manually
redirecting if the javascript isn't allowed, but I'd like provide a more
elegant way.


Re: Upload files message

Hi Bob,

No, in that case you are stuck I think.
Please read Chung Leong's response: He sums up your situation quite

I think I would try his 'invisible frame' solution. At least the visitor can
continue browsing.

Good luck!
Erwin Moller

Re: Upload files message

Quoted text here. Click to load it

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.

The only thing I can think of is to post into an invisible frame. That would
at least allow your user to continue to browse the site while the upload is
occuring. The old problem remains though, with the user staring at the form
not knowing that something is happening.

To sum it up: there's no good solution to this dilemma that would satisfy
your restriction. My advise is to just screw those who disable Javascript.
What can be expected when you go and cripple your browser? A crummier web
browsing experience that's what.

Re: Upload files message

Chung Leong wrote:
Quoted text here. Click to load it

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

Re: Upload files message

Quoted text here. Click to load it

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?

Re: Upload files message

Quoted text here. Click to load it

I'm 2000 light years to understand everything, but for what it's worth, what
about having a function that just write a simple dot "." every 1 or 2
seconds, with a flush, until the file is totally saved. It doesn't need
javascript. Also, I will think about redirecting to the new page if
javascript is activated, or show a link or button if javascript isn't

As I'm not so advanced to do so in PHP, could somebody help me ?


Re: Upload files message

Quoted text here. Click to load it

No, it cannot be done. Eventhough it sounds very simple, it cannot be done.
The assumption is built into the server software that the input is
completely process before output begins. While the file upload is occuring
PHP cannot output anything to the browser--not even a dot.

Re: Upload files message

Bob Bedford wrote:
Quoted text here. Click to load it
worth, what


Without Javascript, it seems to be impracticable. But, I have a
slight confidence that it can be achieved with a combination of this
PHP hack <http://pdoru.from.ro/upload-progress-meter/ , Status 204,
iframe, etc.

<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog: http://rajeshanbiah.blogspot.com /

Site Timeline