When a file uploads, it first inserts the data into the database and then uploads the file to avoid the "MySQL Server has gone away" error, my timeout is 30 seconds. My MAX_FILE_SIZE is 128 MegaBytes, so if it's a large file uploading I want to know if it is uploading and not finished - the primary reason for this is because the staff members who check the file will see the "X new files" when they login, based on the database. Since the file uploads last, it might not be on the server when they see the "X new files" so might delete the file thinking the file is corrupt. I would therefore like (if possible) for a way to check if files are uploading. If my way is not possible, could someone give me some other advice on what to do?
Thanks.
Code: Select all
<?php
if ($pun_user['downloads_moderator'] == '1' || $pun_user['g_global_moderator'] == '1' || $pun_user['g_id'] == PUN_ADMIN)
{
$uploading_files = '0';
$uploaded_files = '0';
$admmod = $shn_sites->prepare("SELECT COUNT(*) AS id FROM downloads_unchecked");
$admmod->execute();
$count = $admmod->fetch();
$admmod = $shn_sites->prepare("SELECT file FROM downloads_unchecked");
$admmod->execute();
foreach ($admmod as $row)
{
while (!file_exists('/home/**DIRECTORIES**/'.$row['file'].''))
{
$uploading_files = $uploading_files + 1;
}
while (file_exists('/home/**DIRECTORIES**/'.$row['file'].''))
{
$uploaded_files = $uploaded_files + 1;
}
}
?>
<div class="boxed">
<h2 class="heading">Admin</h2>
<div class="content">
<ul>
<?php
if ($count['id'] > 0)
{
?>
<li class="first"><a href='http://admin.mysite.com/'><?php echo $uploaded_files; ?> New Files</a></li>
<?php
}
else
{
?>
<li class="first"><a href='http://admin.mysite.com/'>No New Files</a></li>
<?php
}
$admmod2 = $shn_sites->prepare("SELECT COUNT(*) AS id FROM downloads WHERE approval = '1'");
$admmod2->execute();
foreach ($admmod2 as $row)
{
if ($row['id'] > 0)
{
?>
<li><a href="http://admin.mysite.com/updated_files.php"><?php echo $row['id']; ?> Updated Files</a></li>
<?php
}
else
{
?>
<li><a href="http://admin.mysite.com/updated_files.php">No Updated Files</a></li>
<?php
}
}
if ($uploading_files > 0)
{
?>
<li><strong><?php echo $uploading_files; ?> Files Currently Uploading</strong></li>
<?php
}
else
{
?>
<li>No Files Currently Uploading</li>
<?php
}
?>
</ul>
</div>
</div>
<?php
}
?>