Jump to content

Directory or File Check


nblackwood

Recommended Posts

Excuse the sloppyness...

 

<?php


$DefaultDir = "c:\\";

if(!isset($_POST['NewDir']))
{
$d = @scandir($DefaultDir);
}
else
{
$d = @scandir($_POST['NewDir']);
}

function ChangeDirectory()
{
@chdir($_POST['NewDir']);
}


if(is_dir($val))
{
$icon = 'images/Folder.png';
}
else
{
       $icon = 'images/File.png';
}

if(isset($_POST['Go']))
{
ChangeDirectory();
@getcwd();
}



?>


<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  <p>
  <input name="NewDir" type="text" /><input name="Go" type="submit" value="Go"/>
<?php 
foreach ($d as $key => $val)
{


?>

<table width=auto height=auto border=0>
  <tr>
    <td><img src="<?php echo $icon;?>" width=16 height=16></td>
    <td><?php echo $val;?></td>
    <td><input name="cmd[]" type="checkbox" value="<?php echo $val;?>"/></td>
</tr>
</table>
<?php
}

"<br><br>"
?>
<?php  

  $Command = $_POST['cmd'];

if(isset($_POST['submit']))
{


?>
<table width="auto" height="auto" border="0">
  <tr>
  <td><?php for ($i=0; $i < count($_POST['cmd']);$i++) {
echo "<br>".$_POST['cmd'][$i];
}
?></td> 
  </tr>
</table>
<?php
}


?>

  <p>
    <input name="submit" type="submit" value="Submit">
  </p>
</form>

Link to comment
Share on other sites

You are kind of asking someone who is not standing right beside you to magically know what your code is (and the few lines you did post is not all the relevant code because that does not show how you are getting the data and what processing you are doing to it), what the actual data values are, what data value is failing (and what are some of the ones that work), and what results you ARE getting for those data values vs the expected results.

 

Had you simply included in your first post in this thread -

 

1) All the code (someone could duplicate the problem in a few minutes and tell you what to do to fix it),

2) Some actual data values you are using that work and does not work,

3) What result you are getting for each piece of that data.

 

I'm going to guess this has something to do with slashes /, but since you haven't shown anything you have seen in front of you when you do this. it's kind of hard to guess what sort of problem you are having.

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.