File that was put to search barFile inside directory?
$usersSearch = "hello";
$files = glob("folders/*$usersSearch*.*");
if(count($files) > 0){
foreach($files as $file){
$info = pathinfo($file);
echo "File found";
}
}
Yeah I was not asking for javascript code xDWell Javascript is a locally ran (on client side) meaning you will not be able to access the files using javascript. So you will have to use a 'POST' search with php to able to locally source the file names, types, etc. securely and safely.
Php function glob() would be best for this...
Here is a small example:
Code:$usersSearch = "hello"; $files = glob("folders/*$usersSearch*.*"); if(count($files) > 0){ foreach($files as $file){ $info = pathinfo($file); echo "File found"; } }
$where_post = $_POST['find_where'];
$text = $_POST['text'];
if($where_post == 'Anywhere') {
$where = 'folders/';
}
elseif ($where_post == 'CMS') {
$where = 'folders/CMS/';
}
elseif ($where_post == 'Emulator') {
$where = 'folders/Emulator/';
}
elseif ($where_post == 'Full Packs') {
$where = 'folders/Full Packs/';
}
elseif ($where_post == 'Furni Packs') {
$where = 'folders/Furni Packs/';
}
elseif ($where_post == 'SQL') {
$where = 'folders/SQL/';
}
elseif ($where_post == 'SWF') {
$where = 'folders/SWF/';
}
$files = glob("../".$where."/*". $text ."*.*");
if(count($files[0]) > 0){
foreach($files as $file){
$info = pathinfo($file);
$name = basename($files);
?>
<div style="width:400px; padding:20px; border-bottom:1px solid white;">
<div style="width:100px;height:100px; border:1px solid white; background:<?= $color; ?>" name="icon">
<div class='tile-icon'>
<span class='icon mif-folder mif-4x' style="padding:20px;"></span>
</div>
</div>
<div style="float: right; cursor: auto; z-index: auto; position: relative; top: -100px; left: -133px;"><h3>CMS 1.zip</h3></div>
<div style="float: right; cursor: auto; z-index: auto; position: relative; top: -1px; left: 75px;">size</div>
<div id="text">
click 2 downl04d
</div>
</div>
<?php
}
}
else {
die('No files found.');
}
?>
$files = glob("../".$where."/*". $text ."*.*");
$files = glob("../".$where."/*". $text ."*");
$files = glob("../".$where."/*". $text ."*", GLOB_NOCHECK);
die('No files found.');
var_dump($files);
exit;
It worked but, It only shows while there is two (contains unneeded checks.PHP:$files = glob("../".$where."/*". $text ."*.*");
is enough.PHP:$files = glob("../".$where."/*". $text ."*");
However, for debugging purposes, please add the GLOB_NOCHECK flag like so:
PHP:$files = glob("../".$where."/*". $text ."*", GLOB_NOCHECK);
and instead of
doPHP:die('No files found.');
PHP:var_dump($files); exit;
and post the results.
<?php
$files = glob("../".$where."/*". $text ."*", GLOB_NOCHECK);
if(count($files) > 0){
foreach($files as $file){
$info = pathinfo($file);
$name = explode('* ',basename($files));
?>
<div style="width:400px; padding:20px; border-bottom:1px solid white;">
<div style="width:100px;height:100px; border:1px solid white; background:<?= $color; ?>" name="icon">
<div class='tile-icon'>
<span class='icon mif-folder mif-4x' style="padding:20px;"></span>
</div>
</div>
<div style="float: right; cursor: auto; z-index: auto; position: relative; top: -100px; left: -133px;"><h3><?= basename($file); ?></h3></div>
<div style="float: right; cursor: auto; z-index: auto; position: relative; top: -1px; left: 75px;"><?= filesize($file); ?></div>
<div id="text">
click 2 downl04d
</div>
</div>
<?php
}
}
else {
var_dump($files);
exit;}
?>
Also result is :It worked but, It only shows while there is two (You must be registered for see links).
PHP Code ATM:
PHP:$files = glob("../".$where."/*". $text ."*", GLOB_NOCHECK); if(count($files) > 0){ foreach($files as $file){ $info = pathinfo($file); $name = explode('* ',basename($files)); ?> <div style="width:400px; padding:20px; border-bottom:1px solid white;"> <div style="width:100px;height:100px; border:1px solid white; background:<?= $color; ?>" name="icon"> <div class='tile-icon'> <span class='icon mif-folder mif-4x' style="padding:20px;"></span> </div> </div> <div style="float: right; cursor: auto; z-index: auto; position: relative; top: -100px; left: -133px;"><h3><?= basename($file); ?></h3></div> <div style="float: right; cursor: auto; z-index: auto; position: relative; top: -1px; left: 75px;"><?= filesize($file); ?></div> <div id="text"> click 2 downl04d </div> </div> <?php } } else { var_dump($files); exit;} ?>