By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Upload files message

P: n/a
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 ?

Bob
Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Bob Bedford wrote:
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 ?

Bob

Hi Bob,

I am unsure if it is just me, but I cannot follow your question.
Are you asking how you can show a nicely formatted UPLOAD-page during the
upload-process?

Or do you have some error?
Or do you wonder why you cannot add headers?
Which headers do you want to add?
And why?
etc.

Please rephrase your question.

Regards,
Erwin Moller

Jul 17 '05 #2

P: n/a

"Erwin Moller"
<si******************************************@spam yourself.com> a écrit dans
le message de news: 41**********************@news.xs4all.nl...
Bob Bedford wrote:
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 ?

Bob

Hi Bob,

I am unsure if it is just me, but I cannot follow your question.
Are you asking how you can show a nicely formatted UPLOAD-page during the
upload-process?

Or do you have some error?
Or do you wonder why you cannot add headers?
Which headers do you want to add?
And why?
etc.

Please rephrase your question.

Regards,
Erwin Moller

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...)
like:
echo('<br>start uploading'.$filename1);
flush;
//upload code here
echo('<br>upload successfull'.$filename1);
flush;
.....
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
header('location:...');

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.

Bob
Jul 17 '05 #3

P: n/a
"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, 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.


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.
Jul 17 '05 #4

P: n/a
Hi Bob,

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

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

Good luck!
Regards,
Erwin Moller
Jul 17 '05 #5

P: n/a
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, 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.

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>

Jul 17 '05 #6

P: n/a
"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?
Jul 17 '05 #7

P: n/a

"Chung Leong" <ch***********@hotmail.com> a écrit dans le message de news:
7v********************@comcast.com...
"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, 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.
>
>
> 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?


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
enabled.

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

Bob
Jul 17 '05 #8

P: n/a

"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com> wrote in message
news:41**********************@news.sunrise.ch...
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
enabled.


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.

Jul 17 '05 #9

P: n/a
Bob Bedford wrote:
<snip>
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 enabled.


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/

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.