![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Code snippet: if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) { $html .= $font . '<font color=cc0000><li>Could not open files in content folder</li></font></font><p>'; } else if ($hasCookie) { clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY DETERMINE FILE STATUS $html .= $font . 'Contents: <p>'; while (($file = readdir($dirID)) !== false) { if (is_file($file) || !preg_match('/^\./', $file)) { $html .= "\n<br><a href=/content/" . substr($file, strrpos('/', $file), strlen($file)) . '>' . substr($file, strrpos('/', $file), strlen($file)) . "</a><p>\n"; } } } where $ACTUAL_STARTPATH is the actual path for each file. However, whenever I try to check to see if a read file is an actual file and not either a directory, '.' nor '..', it constantly skips every legitimate file! These files have extensions of .html, .txt, .doc, .pdf, etc. Is is_dir() then a failed PHP command? Phil | |||
| Advertisements |
| | #2 | ||
| On Mon, 18 Aug 2003 02:43:07 -0400, "Phil Powell" <soazine@erols.com> wrote: >Code snippet: > >if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) { > $html .= $font . '<font color=cc0000><li>Could not open files in content >folder</li></font></font><p>'; > } else if ($hasCookie) { > > clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY >DETERMINE FILE STATUS > $html .= $font . 'Contents: <p>'; > while (($file = readdir($dirID)) !== false) { > if (is_file($file) || !preg_match('/^\./', $file)) { readdir returns filenames only, not paths. You're getting is_file to look at the wrong directory, unless the current directory happens to be the one you're scanning with opendir. | |||
| | #3 | ||
| That wasn't the problem; the problem was that the files were of permission 0700 along with the folder. It was physically unable to open the directory, much less the files. I gave up on a PHP solution and wrote it in TCL CGI and it works. Thanx though Phil "Andy Hassall" <andy@andyh.co.uk> wrote in message news:9uf1kvsfvbpfgehmuthl1m9fo7ilumit6v@4ax.com... > On Mon, 18 Aug 2003 02:43:07 -0400, "Phil Powell" <soazine@erols.com> > wrote: > > >Code snippet: > > > >if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) { > > $html .= $font . '<font color=cc0000><li>Could not open files in content > >folder</li></font></font><p>'; > > } else if ($hasCookie) { > > > > clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY > >DETERMINE FILE STATUS > > $html .= $font . 'Contents: <p>'; > > while (($file = readdir($dirID)) !== false) { > > if (is_file($file) || !preg_match('/^\./', $file)) { > > readdir returns filenames only, not paths. You're getting is_file to > look at the wrong directory, unless the current directory happens to > be the one you're scanning with opendir. > | |||
| Featured Websites | ||||
|
![]() |
| Tags: actual, fails, files, is_file |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying Actual Font Samples in PS7+ | Stan Shankman | Graphics in general | 9 | 06-11-2007 10:38 PM |
| UDF Function adding fails | Adam | Database | 0 | 06-10-2007 12:22 AM |
| MySQL fails on startup | Jos Forger | Database | 0 | 05-31-2007 8:41 PM |
| xbox live fails on ip test!!!! | ste1701 | Computer Consoles | 3 | 03-03-2007 11:33 AM |
| Featured Websites | ||||
|