determine file-upload's tmp-filename

This is a discussion on determine file-upload's tmp-filename within the PHP General forums, part of the PHP Programming Forums category; hi there, is there a way to determine the tmp-filename of a file upload while the upload is still ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-26-2008
Michael Fischer
 
Posts: n/a
Default determine file-upload's tmp-filename

hi there,

is there a way to determine the tmp-filename of a file upload while the upload is still in progress?

the tmp-file is stored in /tmp and it's name is something like PHPXXXXXXXX.

what i would like to do is:
i want to upload a file via a html-form and while the upload is in progress make repeatedly ajax-requests to a php-script on the server that replies the size of the tmp file (the amount of data that was already uploaded). So in this script i need to know what the tmp-filename is.

or do you think this is a completely useless approach?

lg, Michi
Reply With Quote
  #2 (permalink)  
Old 01-27-2008
Casey
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename

On Jan 26, 2008 3:57 PM, Michael Fischer <michi.fischer@gmx.net> wrote:
> hi there,
>
> is there a way to determine the tmp-filename of a file upload while the upload is still in progress?
>
> the tmp-file is stored in /tmp and it's name is something like PHPXXXXXXXX.
>
> what i would like to do is:
> i want to upload a file via a html-form and while the upload is in progress make repeatedly ajax-requests to a php-script on the server that replies the size of the tmp file (the amount of data that was already uploaded). So in this script i need to know what the tmp-filename is.
>
> or do you think this is a completely useless approach?
>
> lg, Michi
>



Will this help?
http://tomas.epineer.se/archives/3

--
-Casey
Reply With Quote
  #3 (permalink)  
Old 01-27-2008
Michael Fischer
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename


-------- Original-Nachricht --------
> Datum: Sat, 26 Jan 2008 16:09:58 -0800
> Von: Casey <heavyccasey@gmail.com>
> An: "Michael Fischer" <michi.fischer@gmx.net>
> CC: php-general@lists.php.net
> Betreff: Re: [php] determine file-upload\'s tmp-filename


> On Jan 26, 2008 3:57 PM, Michael Fischer <michi.fischer@gmx.net> wrote:
> > hi there,
> >
> > is there a way to determine the tmp-filename of a file upload while the

> upload is still in progress?
> >
> > the tmp-file is stored in /tmp and it's name is something like

> PHPXXXXXXXX.
> >
> > what i would like to do is:
> > i want to upload a file via a html-form and while the upload is in

> progress make repeatedly ajax-requests to a php-script on the server that
> replies the size of the tmp file (the amount of data that was already uploaded).
> So in this script i need to know what the tmp-filename is.
> >
> > or do you think this is a completely useless approach?
> >
> > lg, Michi
> >

>
>
> Will this help?
> http://tomas.epineer.se/archives/3
>
> --
> -Casey


well, i've found this before and this script uses perl-cgi and not php.
it determines the tmp-filename as such:

$post_data_file = "$tmp_dir/$sessionid"."_postdata";
$monitor_file = "$tmp_dir/$sessionid"."_flength";
$error_file = "$tmp_dir/$sessionid"."_err";
$signal_file = "$tmp_dir/$sessionid"."_signal";
$qstring_file = "$tmp_dir/$sessionid"."_qstring";

i'm looking for something similar in php...

lg, michi
Reply With Quote
  #4 (permalink)  
Old 01-27-2008
Brady Mitchell
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename

On Jan 26, 2008, at 357PM, Michael Fischer wrote:

> hi there,
>
> is there a way to determine the tmp-filename of a file upload while
> the upload is still in progress?


I'm not sure when it becomes available, but $_FILES['file_name']
['tmp_name'] is the only place I know of to find the temporary name.

> the tmp-file is stored in /tmp and it's name is something like
> PHPXXXXXXXX.
>
> what i would like to do is:
> i want to upload a file via a html-form and while the upload is in
> progress make repeatedly ajax-requests to a php-script on the server
> that replies the size of the tmp file (the amount of data that was
> already uploaded). So in this script i need to know what the tmp-
> filename is.


You could try doing a print_r($_GLOBALS); in that script to find out
if there are any other helpful places to check.

HTH,

Brady
Reply With Quote
  #5 (permalink)  
Old 01-27-2008
Michael Fischer
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename


-------- Original-Nachricht --------
> Datum: Sun, 27 Jan 2008 01:21:19 -0800
> Von: Brady Mitchell <mydarb@gmail.com>
> An: Michael Fischer <michi.fischer@gmx.net>
> CC: php-general@lists.php.net
> Betreff: Re: [php] determine file-upload\'s tmp-filename


> On Jan 26, 2008, at 357PM, Michael Fischer wrote:
>
> > hi there,
> >
> > is there a way to determine the tmp-filename of a file upload while
> > the upload is still in progress?

>
> I'm not sure when it becomes available, but $_FILES['file_name']
> ['tmp_name'] is the only place I know of to find the temporary name.
>
> > the tmp-file is stored in /tmp and it's name is something like
> > PHPXXXXXXXX.
> >
> > what i would like to do is:
> > i want to upload a file via a html-form and while the upload is in
> > progress make repeatedly ajax-requests to a php-script on the server
> > that replies the size of the tmp file (the amount of data that was
> > already uploaded). So in this script i need to know what the tmp-
> > filename is.

>
> You could try doing a print_r($_GLOBALS); in that script to find out
> if there are any other helpful places to check.
>
> HTH,
>
> Brady
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


hm, there's nothing to spectacular in $_GLOBALS:

Array
(
[GLOBALS] => Array
*RECURSION*
[_ENV] => Array
(
[TERM] => xterm
[SHELL] => /bin/bash
[DEFAULTLEVEL] => default
[LC_ALL] => de_DE@euro
[USER] => root
[PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/i386-pc-linux-gnu/gcc-bin/3.4.4
[PWD] => /etc/apache2/modules.d
[LANG] => de_DE@euro
[BOOTLEVEL] => boot
[SVCNAME] => apache2
[CONSOLETYPE] => pty
[SHLVL] => 1
[HOME] => /home/albert
[SOFTLEVEL] => default
[_] => /usr/sbin/apache2
)

[HTTP_ENV_VARS] => Array
(
[TERM] => xterm
[SHELL] => /bin/bash
[DEFAULTLEVEL] => default
[LC_ALL] => de_DE@euro
[USER] => root
[PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/i386-pc-linux-gnu/gcc-bin/3.4.4
[PWD] => /etc/apache2/modules.d
[LANG] => de_DE@euro
[BOOTLEVEL] => boot
[SVCNAME] => apache2
[CONSOLETYPE] => pty
[SHLVL] => 1
[HOME] => /home/albert
[SOFTLEVEL] => default
[_] => /usr/sbin/apache2
)

[_POST] => Array
(
)

[HTTP_POST_VARS] => Array
(
)

[_GET] => Array
(
)

[HTTP_GET_VARS] => Array
(
)

[_COOKIE] => Array
(
[PHPSESSID] => a959c533aa718bc94801431ae34f6fa6
)

[HTTP_COOKIE_VARS] => Array
(
[PHPSESSID] => a959c533aa718bc94801431ae34f6fa6
)

[_SERVER] => Array
(
[UNIQUE_ID] => 6jqHi38AAAEAAHn7e14AAAAJ
[HTTP_X_REQUESTED_WITH] => XMLHttpRequest
[HTTP_ACCEPT_LANGUAGE] => de-at,en-us;q=0.5
[HTTP_REFERER] => http://webfischer.at/~albert/upload.php
[HTTP_ACCEPT] => text/javascript, text/html, application/xml, text/xml, */*
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)
[HTTP_HOST] => webfischer.at
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => PHPSESSID=a959c533aa718bc94801431ae34f6fa6
[PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/i386-pc-linux-gnu/gcc-bin/3.4.4
[SERVER_SIGNATURE] => Apache Server at webfischer.at Port 80

[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => webfischer.at
[SERVER_ADDR] => 192.168.0.2
[SERVER_PORT] => 80
[REMOTE_ADDR] => 193.80.38.250
[DOCUMENT_ROOT] => /var/www/htdocs
[SERVER_ADMIN] => root@localhost
[SCRIPT_FILENAME] => /home/albert/public_html/upload2.php
[REMOTE_PORT] => 62795
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /~albert/upload2.php
[SCRIPT_NAME] => /~albert/upload2.php
[PHP_SELF] => /~albert/upload2.php
[REQUEST_TIME] => 1201426541
[argv] => Array
(
)

[argc] => 0
)

[HTTP_SERVER_VARS] => Array
(
[UNIQUE_ID] => 6jqHi38AAAEAAHn7e14AAAAJ
[HTTP_X_REQUESTED_WITH] => XMLHttpRequest
[HTTP_ACCEPT_LANGUAGE] => de-at,en-us;q=0.5
[HTTP_REFERER] => http://webfischer.at/~albert/upload.php
[HTTP_ACCEPT] => text/javascript, text/html, application/xml, text/xml, */*
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)
[HTTP_HOST] => webfischer.at
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => PHPSESSID=a959c533aa718bc94801431ae34f6fa6
[PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/i386-pc-linux-gnu/gcc-bin/3.4.4
[SERVER_SIGNATURE] => Apache Server at webfischer.at Port 80

[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => webfischer.at
[SERVER_ADDR] => 192.168.0.2
[SERVER_PORT] => 80
[REMOTE_ADDR] => 193.80.38.250
[DOCUMENT_ROOT] => /var/www/htdocs
[SERVER_ADMIN] => root@localhost
[SCRIPT_FILENAME] => /home/albert/public_html/upload2.php
[REMOTE_PORT] => 62795
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /~albert/upload2.php
[SCRIPT_NAME] => /~albert/upload2.php
[PHP_SELF] => /~albert/upload2.php
[REQUEST_TIME] => 1201426541
[argv] => Array
(
)

[argc] => 0
)

[_FILES] => Array
(
)

[HTTP_POST_FILES] => Array
(
)

[_REQUEST] => Array
(
[PHPSESSID] => a959c533aa718bc94801431ae34f6fa6
)

[HTTP_SESSION_VARS] => Array
(
)

[_SESSION] => Array
(
)

)

wicked...

does anybody know what happens if the form-action is a simple html-file? where will the tmp-file be stored?

lg, michi
Reply With Quote
  #6 (permalink)  
Old 01-27-2008
Andrés Robinet
 
Posts: n/a
Default RE: [PHP] determine file-upload's tmp-filename

> -----Original Message-----
> From: Michael Fischer [mailto:michi.fischer@gmx.net]
> Sent: Sunday, January 27, 2008 4:03 AM
> To: php-general@lists.php.net
> Subject: Re: [php] determine file-upload's tmp-filename
>
>
> -------- Original-Nachricht --------
> > Datum: Sat, 26 Jan 2008 16:09:58 -0800
> > Von: Casey <heavyccasey@gmail.com>
> > An: "Michael Fischer" <michi.fischer@gmx.net>
> > CC: php-general@lists.php.net
> > Betreff: Re: [php] determine file-upload\'s tmp-filename

>
> > On Jan 26, 2008 3:57 PM, Michael Fischer <michi.fischer@gmx.net>

> wrote:
> > > hi there,
> > >
> > > is there a way to determine the tmp-filename of a file upload while

> the
> > upload is still in progress?
> > >
> > > the tmp-file is stored in /tmp and it's name is something like

> > PHPXXXXXXXX.
> > >
> > > what i would like to do is:
> > > i want to upload a file via a html-form and while the upload is in

> > progress make repeatedly ajax-requests to a php-script on the server

> that
> > replies the size of the tmp file (the amount of data that was already

> uploaded).
> > So in this script i need to know what the tmp-filename is.
> > >
> > > or do you think this is a completely useless approach?
> > >
> > > lg, Michi
> > >

> >
> >
> > Will this help?
> > http://tomas.epineer.se/archives/3
> >
> > --
> > -Casey

>
> well, i've found this before and this script uses perl-cgi and not php.
> it determines the tmp-filename as such:
>
> $post_data_file = "$tmp_dir/$sessionid"."_postdata";
> $monitor_file = "$tmp_dir/$sessionid"."_flength";
> $error_file = "$tmp_dir/$sessionid"."_err";
> $signal_file = "$tmp_dir/$sessionid"."_signal";
> $qstring_file = "$tmp_dir/$sessionid"."_qstring";
>
> i'm looking for something similar in php...
>
> lg, michi
>


If all you want is to display a progress bar, you'd better move all of your
logic to the client side. Check this out
http://www.swfupload.org/documentation/demonstration

Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION*
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308
| TEL 954-607-4207*| FAX 954-337-2695 |
Email: info@bestplace.net *| MSN Chat: best@bestplace.net *| *SKYPE:
bestplace | *Web: bestplace.biz* | Web: seo-diy.com

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.11/1244 - Release Date: 1/25/2008
7:44 PM

Reply With Quote
  #7 (permalink)  
Old 01-27-2008
Michael Fischer
 
Posts: n/a
Default RE: [PHP] determine file-upload's tmp-filename

On Sun, 2008-01-27 at 11:12 -0500, Andrés Robinet wrote:
> > -----Original Message-----
> > From: Michael Fischer [mailto:michi.fischer@gmx.net]
> > Sent: Sunday, January 27, 2008 4:03 AM
> > To: php-general@lists.php.net
> > Subject: Re: [php] determine file-upload's tmp-filename
> >
> >
> > -------- Original-Nachricht --------
> > > Datum: Sat, 26 Jan 2008 16:09:58 -0800
> > > Von: Casey <heavyccasey@gmail.com>
> > > An: "Michael Fischer" <michi.fischer@gmx.net>
> > > CC: php-general@lists.php.net
> > > Betreff: Re: [php] determine file-upload\'s tmp-filename

> >
> > > On Jan 26, 2008 3:57 PM, Michael Fischer <michi.fischer@gmx.net>

> > wrote:
> > > > hi there,
> > > >
> > > > is there a way to determine the tmp-filename of a file upload while

> > the
> > > upload is still in progress?
> > > >
> > > > the tmp-file is stored in /tmp and it's name is something like
> > > PHPXXXXXXXX.
> > > >
> > > > what i would like to do is:
> > > > i want to upload a file via a html-form and while the upload is in
> > > progress make repeatedly ajax-requests to a php-script on the server

> > that
> > > replies the size of the tmp file (the amount of data that was already

> > uploaded).
> > > So in this script i need to know what the tmp-filename is.
> > > >
> > > > or do you think this is a completely useless approach?
> > > >
> > > > lg, Michi
> > > >
> > >
> > >
> > > Will this help?
> > > http://tomas.epineer.se/archives/3
> > >
> > > --
> > > -Casey

> >
> > well, i've found this before and this script uses perl-cgi and not php.
> > it determines the tmp-filename as such:
> >
> > $post_data_file = "$tmp_dir/$sessionid"."_postdata";
> > $monitor_file = "$tmp_dir/$sessionid"."_flength";
> > $error_file = "$tmp_dir/$sessionid"."_err";
> > $signal_file = "$tmp_dir/$sessionid"."_signal";
> > $qstring_file = "$tmp_dir/$sessionid"."_qstring";
> >
> > i'm looking for something similar in php...
> >
> > lg, michi
> >

>
> If all you want is to display a progress bar, you'd better move all of your
> logic to the client side. Check this out
> http://www.swfupload.org/documentation/demonstration
>
> Regards,
>
> Rob
>
>
> Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
> 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308
> | TEL 954-607-4207 | FAX 954-337-2695 |
> Email: info@bestplace.net | MSN Chat: best@bestplace.net | SKYPE:
> bestplace | Web: bestplace.biz | Web: seo-diy.com
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.11/1244 - Release Date: 1/25/2008
> 7:44 PM
>
>

You are right, the client side would be the best solution.
BUT - this requires the client to either have flash or java browser
plugin installed. i don't want that.
and i don't know any way in javascript to get the amount of data already
sent - so i thought i'd try on the server-side.

lg, Michi
--
Sautergasse 27-29/35
1160 Wien
phone: 0043 650 2526276
email: michi.fischer@gmx.net
web: http://www.webfischer.at
Reply With Quote
  #8 (permalink)  
Old 01-28-2008
Richard Lynch
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename



On Sat, January 26, 2008 5:57 pm, Michael Fischer wrote:
> hi there,
>
> is there a way to determine the tmp-filename of a file upload while
> the upload is still in progress?
>
> the tmp-file is stored in /tmp and it's name is something like
> PHPXXXXXXXX.
>
> what i would like to do is:
> i want to upload a file via a html-form and while the upload is in
> progress make repeatedly ajax-requests to a php-script on the server
> that replies the size of the tmp file (the amount of data that was
> already uploaded). So in this script i need to know what the
> tmp-filename is.
>
> or do you think this is a completely useless approach?


Google for PHP upload meter instead.

That's probably how it works, more or less...

I still think it's STOOPID to round-trip back and forth to the server
to get an upload progress meter -- The browser developers should be
providing you with some kind of progress notification system locally!

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #9 (permalink)  
Old 01-28-2008
Michael Fischer
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename

On Mon, 2008-01-28 at 12:17 -0600, Richard Lynch wrote:
>
> On Sat, January 26, 2008 5:57 pm, Michael Fischer wrote:
> > hi there,
> >
> > is there a way to determine the tmp-filename of a file upload while
> > the upload is still in progress?
> >
> > the tmp-file is stored in /tmp and it's name is something like
> > PHPXXXXXXXX.
> >
> > what i would like to do is:
> > i want to upload a file via a html-form and while the upload is in
> > progress make repeatedly ajax-requests to a php-script on the server
> > that replies the size of the tmp file (the amount of data that was
> > already uploaded). So in this script i need to know what the
> > tmp-filename is.
> >
> > or do you think this is a completely useless approach?

>
> Google for PHP upload meter instead.
>
> That's probably how it works, more or less...
>
> I still think it's STOOPID to round-trip back and forth to the server
> to get an upload progress meter -- The browser developers should be
> providing you with some kind of progress notification system locally!
>

well, i agree with you - the browser should provide some sort of
functionality to find out the amount of data already sent. but i don't
know any browser that does.

all the php upload meters that i found on google either require to
patch php or use perl.

lg, Michi
--
Sautergasse 27-29/35
1160 Wien
phone: 0043 650 2526276
email: michi.fischer@gmx.net
web: http://www.webfischer.at
Reply With Quote
  #10 (permalink)  
Old 01-28-2008
Nathan Nobbe
 
Posts: n/a
Default Re: [PHP] determine file-upload's tmp-filename

On Jan 28, 2008 2:50 PM, Michael Fischer <michi.fischer@gmx.net> wrote:

> well, i agree with you - the browser should provide some sort of
> functionality to find out the amount of data already sent. but i don't
> know any browser that does.
>
> all the php upload meters that i found on google either require to
> patch php or use perl.
>



its a shame javascript cant hook into the local filesystem, but i think its
just a matter of time until we get there.
http://labs.mozilla.com/2007/10/prism/
anyway im pretty sure you can get this effect w/ a flash plugin, that is a
progress meter that doesnt have to poll the webserver for status info, if
thats what ur after..

-nathan

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 10:15 AM.


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