PHP: Session Upload Progress

Hey Sitepointers,

Can anyone out there shed some light on how I can access the session upload progress variables?

I have this script here that uploads a file.

<?php session_start();
set_time_limit('3600');

if ($_FILES)
{
  print_r($_FILES['uploaded_video']);
  file_put_contents('/var/www/html/video-test/uploads/' . $_FILES["uploaded_video"]["name"],file_get_contents($_FILES['uploaded_video']['tmp_name']));
  echo 'file uploaded';
}
?>

<form method="POST" action="upload.php" enctype="multipart/form-data">
  <input type="file" name="uploaded_video" />
  <input type="submit" value="Upload" />
</form> 

And this other script that I’m trying to use to see uploaded progress

<?php session_start();

print_r($_SESSION);

$key = ini_get("session.upload_progress.prefix") . $_POST[ini_get("session.upload_progress.name")];
var_dump($_SESSION[$key]);
?>

And here is the output of that script while the file is uploading

Array
(
)


Notice:  Undefined index: PHP_SESSION_UPLOAD_PROGRESS in /var/www/html/video-test/upload_progress.php on line 5



Notice:  Undefined index: upload_progress_ in /var/www/html/video-test/upload_progress.php on line 6

NULL

What am I doing wrong here?

Also here is the session information from phpinfo()

session

Session Support enabled 
Registered save handlers files user  
Registered serializer handlers php_serialize php php_binary wddx  



DirectiveLocal ValueMaster Value
session.auto_startOffOff
session.cache_expire180180
session.cache_limiternocachenocache
session.cookie_domainno valueno value
session.cookie_httponlyOffOff
session.cookie_lifetime00
session.cookie_path//
session.cookie_secureOffOff
session.entropy_file/dev/urandom/dev/urandom
session.entropy_length3232
session.gc_divisor10001000
session.gc_maxlifetime14401440
session.gc_probability00
session.hash_bits_per_character55
session.hash_function00
session.namePHPSESSIDPHPSESSID
session.referer_checkno valueno value
session.save_handlerfilesfiles
session.save_path/var/lib/php5/var/lib/php5
session.serialize_handlerphpphp
session.upload_progress.cleanupOnOn
session.upload_progress.enabledOnOn
session.upload_progress.freq1%1%
session.upload_progress.min_freq11
session.upload_progress.namePHP_SESSION_UPLOAD_PROGRESSPHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefixupload_progress_upload_progress_
session.use_cookiesOnOn
session.use_only_cookiesOnOn
session.use_strict_modeOffOff
session.use_trans_sid00

Did you notice hidden field in the form in example here?

1 Like

Ahhh crud! I’ll go try that and see how it works out! Thanks for showing me how to read!

Thanks! That fixed it!

However I get this message as well as the array contents.

Notice: Undefined index: PHP_SESSION_UPLOAD_PROGRESS in /var/www/html/video-test/upload_progress.php on line 5

Notice: Undefined index: upload_progress_ in /var/www/html/video-test/upload_progress.php on line 6
NULL 

And yet it works. Any idea?

I’m not sure how can you get array item contents and message that item doesn’t exist at the same time

Me either. Normally I disable PHP Notice but my System admin says I must have it on the development server. I’ll just throw an @ symbol in front of the statement heh.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.