yayo Posted June 7, 2014 Share Posted June 7, 2014 Hey I've roughly written a php ftp browser (file displayer) and I cant seen to get around the problem how I would navigate through the folders, im fairly new to php and haven't had much experience just wondering that some methods could be for keeping track of what directory I am in and how to navigate up and down through the files and folders, I'm looking for ideas not necessarily solutions.I use a $_GET to tell the script what folder to look through but I want to be able to navigate solely through the hyperlinksHere is my code so far: <?php ini_set('upload_max_filesize', '10M'); ini_set('post_max_size', '10M'); ini_set('max_input_time', 300); ini_set('max_execution_time', 300); $host = ""; $user = ""; $password = ""; $ftp_connection = ftp_connect($host); ftp_login($ftp_connection, $user, $password); if (isset($_GET['page'])) { $path = "/" . $_GET['page']; } else { $path = "/"; } $file_list = ftp_nlist($ftp_connection, $path); echo "<table border=1><tr><td>File Name</td><td>File Size</td><tr>"; for($index = 0; $index < sizeof($file_list); $index++) { echo "<tr>"; $file_size = ftp_size($ftp_connection, $file_list[$index]); $file_name = $file_list[$index]; if ($file_size == -1) { echo "<td><a href=browse.php?page=" . $path . $file_name . ">" . $file_name . "</a></td><td><b>Folder</b></td></tr>"; } else { echo "<td>" . $file_name . "</td><td>" . $file_size . "</td></tr>"; } } ftp_close($ftp_connection); I'm fairly tired so I will sleep on the problem and check back in the morning (it may just be because I'm tired I cant think of a solution) I think ive explained it the best I can this is my first post so any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/289051-my-ftp-browserfile-displayer/ Share on other sites More sharing options...
jazzman1 Posted June 7, 2014 Share Posted June 7, 2014 The script works for me with some little corrections. if (isset($_GET['page'])) { $path = urlencode($_GET['page']); } else { $path = ''; } Example1 (whitout get parameter) URL:10.10.1.5:90/pdo/freaks.php Example2 URL:10.10.1.5:90/pdo/freaks.php?page=6.Years.in.Love.2008 Link to comment https://forums.phpfreaks.com/topic/289051-my-ftp-browserfile-displayer/#findComment-1482172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.