Jump to content

Get File Directory cant read more than 2Gb?


Digiboy

Recommended Posts

Hi guys, I have a sub domain where files are in directories and this page list them however it seems it cant read files more than 2 gb, file is in directory and server company hasnt restricted anything, 

 

all i get is folder is empty, strange thing is when is uploading large files, it shows the file, but as soon as upload is finished it says folder is empty. I have also accessed the file directly and it works and sitting in my directory but wouldnt show on this php page, 

 

Please remember it reads any file up to this size with current code but nothing more than that!

 

Thanks for looking at my code

 

<? define("SITE_ROOT", "http://reels.domain.com/FTP_FILES/") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
include("filesize.php");
$logo = $_REQUEST['logo'];
$com = $_REQUEST['com'];
$loc = $com;
$PATH = $_ENV['DOCUMENT_ROOT'];
$d="/home/content/97/101644/html/reels/$com";
$ar=getDirectorySize($d); 
echo "<title>FTP Reels Viewer / $com / " . $ar['count'] . " files</title>";?>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.3/jquery.backstretch.min.js"></script>
<link href="http://reels.domain.com/FTP_FILES/style.css" rel="stylesheet" type="text/css" />

<!--[if lte IE 6]>
			<link href="<? echo SITE_ROOT ?>styleie6.css" type="text/css" title="MSIE CSS patch" rel="stylesheet" />
<![endif]-->
<style type="text/css">
/*<![CDATA[*/
 div.c1 {text-align: center}
/*]]>*/
</style>
</head>

<body>  
<img src="http://reels.domain.com/FTP_FILES/bg.jpg" alt="background image" id="bg" />
<div class="container">
<?

///if ($logo == "mc") {
echo "<div id=\"mc-header\">";
echo "<p><a href=\"http://domain.com\" target=\"_blank\"><img src=\"" . SITE_ROOT . "logo_2.png\" alt=\"mc_logo\" border=\"none\"/></a></p>";
echo "</div>"; 
///}

?>
<div class="contentmc">
<div align="center">
	
  <?php
    if ($com == "") {
	echo "there is an error, please re-check your link.";
} else {
	
$dir = opendir($d); #open directory

if ($ar['count'] == "0"){
	echo "sorry the folder is empty.";
} else {
while ($f = readdir($dir)) { #read one file name
if ($f != "." && $f != ".." && $f != ".htaccess" && $f != "logo.png" && $f != "logo_2.png") {
echo "<table width=\"500px\"><tr>";
$pieces = explode(".", $f);

natsort($pieces);
//sort($pieces, ksort($pieces));
if (!isset($pieces[1])) { echo "its a directory -->"; $nf = $_REQUEST['com']; $f = "" . $pieces[0]; };
 echo "<td align=\"right\" width=\"250px\"> <a href=\"/$com/$f\" title=\"right click and save as to download " . $pieces[0] . "\">" . $pieces[0] . "</a>  </td> <td align=\"left\" width=\"75px\"> (.". $pieces[1] .")<br /></td><td width=\"20px\"><a href=\"../$com/$f\" title=\"download this file\"><img src=\"" . SITE_ROOT . "black_down.png\" alt=\"download\" border=\"none\"></a></td>\n";
 }
 echo "</tr></table>\n";
 }
 
 echo "<br /><br />You are in the ";
echo "<a href=\"\" title=\"$loc\">" . $loc . "</a>";
 echo " directory";
echo "<br />";
echo "<p>Left click to view the files.</p>";
echo "<p>Right click to save them on your computer (hold down CTRL & click on a Mac). </p>";
}
closedir($dir);
?>
  <p></div>
</div>



<div class="footer"><div class="footer-text">
<?
echo "This folder is using a total of: ".sizeFormat($ar['size'])." and contains ".$ar['count']." files.<br /><br />";
?>
Please remember to download your files within 3 days, as it will automatically be removed after this period. | <a href="mailto:naz@madcowfilms.co.uk?subject=<?echo $com;?>%20error&body=please%20describe%20your%20error">support</a>
</div></div>
</div>
<? } ?>
<!-- OH GOOGIE -->

</body>
</html>

 

 

Link to comment
Share on other sites

Every time when you're looping through the files of that particular directory you are calling the explode function, this is a waste of memory of the server.

What would be happened if you have 2000 files there?

To be more specific turn on error_reporting on the top of that file and give us back the error:

error_reporting(-1);
Link to comment
Share on other sites

Also this is wrong way:

 

/* This is the WRONG way to loop over the directory. */
while ($f = readdir($dir)) { #read one file name


/* This is the correct way to loop over the directory. */
while (false !== ($f = readdir($dir))) { #read one file name

I'm pretty sure that you must redesign this scrit

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.