Jump to content

cropping a value


M.O.S. Studios

Recommended Posts

hey guys, is there a funtion that can crop off all characters after the first 6 letters

 

here is the code im using

 

<?php

// setting Directory
$directory = "upload";

if($_POST['directory'] && $_POST['directory']!="upload")
{
  $directory = $_POST['lower']."/".$_POST['directory'];  
}

if($_POST['change'])
{
  $directory = $_POST['change'];  
}

//Opening the directory; 
$dir = opendir($directory);

?>

<form method="POST" action="index.php">
<?php
echo "<i>PATH:</i> <input type='text' size='100%' name='change' value='".$directory."'><input type='submit' value='Change dir'><br>";
?>
<a href='index.php'><i>root</i></a>
<br><br>
</form>

<form method="POST" action="index.php">
<?php

//displaying contents

while($file = readdir($dir))
{
  if($file!="." && $file != "..")
  {
   if(!stristr($file, "."))
   {
    $dirs .="<input type='submit' name='directory' value='".$file."'>"."<br>"."\n";
   }
   else
   {
    $files .=$file."<br>"."\n";
   }
  }
}

echo $dirs;
echo $files;
?>

<input type="hidden" value="<?php echo $directory; ?>" name="lower">

</form>

 

 

basicly i want to make the code check to varify that the dir stays within the upload directory

 

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/140547-cropping-a-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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