Upload files message

This is a discussion on Upload files message within the PHP Language forums, part of the PHP Programming Forums category; I've a page where the user may enter some values and upload some pictures. Unfortunately, some pictures coming from ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-06-2005
Bob Bedford
 
Posts: n/a
Default Upload files message

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


Reply With Quote
  #2 (permalink)  
Old 01-06-2005
Erwin Moller
 
Posts: n/a
Default Re: Upload files message

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

Reply With Quote
  #3 (permalink)  
Old 01-06-2005
Bob Bedford
 
Posts: n/a
Default Re: Upload files message


"Erwin Moller"
<since_humans_read_this_I_am_spammed_too_much@spam yourself.com> a écrit dans
le message de news: 41dd5dfd$0$6203$e4fe514c@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


Reply With Quote
  #4 (permalink)  
Old 01-07-2005
Chung Leong
 
Posts: n/a
Default Re: Upload files message

"Bob Bedford" <bedford1@YouKnowWhatToDoHerehotmail.com> wrote in message
news:41dcfde7$0$3399$5402220f@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.


Reply With Quote
  #5 (permalink)  
Old 01-07-2005
Erwin Moller
 
Posts: n/a
Default 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
accurate.

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

Good luck!
Regards,
Erwin Moller
Reply With Quote
  #6 (permalink)  
Old 01-07-2005
Dani CS
 
Posts: n/a
Default Re: Upload files message

Chung Leong wrote:
> "Bob Bedford" <bedford1@YouKnowWhatToDoHerehotmail.com> wrote in message
> news:41dcfde7$0$3399$5402220f@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>

Reply With Quote
  #7 (permalink)  
Old 01-08-2005
Chung Leong
 
Posts: n/a
Default Re: Upload files message

"Dani CS" <contusiones.merluza@yahoo.es.quita-la-merluza> wrote in message
news:crm3nm$ag9$1@news.ya.com...
> Chung Leong wrote:
> > "Bob Bedford" <bedford1@YouKnowWhatToDoHerehotmail.com> wrote in message
> > news:41dcfde7$0$3399$5402220f@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?


Reply With Quote
  #8 (permalink)  
Old 01-09-2005
Bob Bedford
 
Posts: n/a
Default Re: Upload files message


"Chung Leong" <chernyshevsky@hotmail.com> a écrit dans le message de news:
7vCdnVyUndnBv0LcRVn-tA@comcast.com...
> "Dani CS" <contusiones.merluza@yahoo.es.quita-la-merluza> wrote in message
> news:crm3nm$ag9$1@news.ya.com...
>> Chung Leong wrote:
>> > "Bob Bedford" <bedford1@YouKnowWhatToDoHerehotmail.com> wrote in
>> > message
>> > news:41dcfde7$0$3399$5402220f@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


Reply With Quote
  #9 (permalink)  
Old 01-12-2005
Chung Leong
 
Posts: n/a
Default Re: Upload files message


"Bob Bedford" <bedford1@YouKnowWhatToDoHerehotmail.com> wrote in message
news:41e16468$0$3408$5402220f@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.



Reply With Quote
  #10 (permalink)  
Old 01-12-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: Upload files message

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/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0