Jump to content

How do you display the PHP upload tmp_file name while the file is being uploaded


magic8ball

Recommended Posts

Because PHP works sequentially, I do not know if this is possible or not.

I am trying to determine how to extract the tmp_file name for a file upload WHILE the file is being uploaded.

My goal is to generate a popup window that will display the size of the php tmp_file so I can watch it grow as the file is uploading (this is what test.php does)

For example:
----------------------------------------------------------------------------
form_upload excerpt code
----------------------------------------------------------------------------
...
$MYFILE=( $_FILES[$fname]['tmp_name'])
include("popup.php")
...
----------------------------------------------------------------------------

----------------------------------------------------------------------------
popup.php
----------------------------------------------------------------------------
<?
$tmpfile= basename($_FILES[$fname]['tmp_name']);
$file= basename($_FILES[$fname]['name']);
echo "TEST<br><hr><br>
    <SCRIPT LANGUAGE='Javascript'>
    <!--
    window.open('test.php?file=$file&tmpfile=$tmpfile','name','height=200,width=400,status=yes,toolbar=no,menubar=no,location=no');
    //-->
    </SCRIPT> ";
return('form_upload.php');
?>
------------------------------------------------------------------------------------
test.php
----------------------------------------------------------------------------
<html><head>
<script type="text/javascript">
<!-- Begin
function reFresh() {
  location.reload(true)
}
window.setInterval("reFresh()",1800);
// End -->
</script>
</head>
<?

$file= $HTTP_GET_VARS['file'];
$tmpfile= $HTTP_GET_VARS['tmpfile'];
$filename = "/var/php/$tmpfile";
if (file_exists($filename)) {
$fp = fopen("$filename", "r");
$temp_file=filesize($filename);
fclose($fp);
};
echo "
  Uploaded File = $file<BR>
  File Name = $filename<BR>
  ";
if (file_exists($filename)) {
  echo "
  File Size = $temp_file<BR> 
  ";
  }
?>
----------------------------------------------------------------------------


I know MYFILE will gather the name of the tmp_name, however when I write upload code I can only get the tmp_name (MYFILE) to display AFTER the file is already uploaded.

Doesn't PHP assign the php tmp_name and then begin uploading the file?

Is there any way to launch a separate thread so I can initiate the "include" of the popup.php WHILE the file is being uploaded instead of waiting until it is complete

Thanks,

-Magic <8> Ball


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.