could i search images in a folder using php in offline

Reply

Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

could i search images in a folder using php in offline

 
0
  #1
Dec 22nd, 2008
hi,
I am a new member of daniwab. Pl, help me. Just i want php codings to search images in a folder(including subfolders) in my drive. Search is just like windows search program.
But i want to search images without using database. Just i type any code word (for eg:- fruits) in the search box, then it will displays all the fruits in my folder(including subfolders)
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: could i search images in a folder using php in offline

 
0
  #2
Dec 22nd, 2008
Hi,
Your problem is solved or you still facing problem ??
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: could i search images in a folder using php in offline

 
0
  #3
Dec 22nd, 2008
Originally Posted by Aamit View Post
Hi,
Your problem is solved or you still facing problem ??
Hi Aamit,
Thanks in advance for trying to solve my problem. I didn't sove this problem. Pl help me if you know the way.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: could i search images in a folder using php in offline

 
0
  #4
Dec 22nd, 2008
Yes It's possible to search files on your drive like c: or d: or e:
  1. $search="DIR /s e:\*.gif>>out.txt";
  2. system ($search);
Here you use dir windows command to search *.gif images on
e: (e drive) and store result in out.txt file

If you check out.txt file you will see all result like search function.
DIR /s e:\*.gif>>out.txt
In this >>out.txt to write result in out.txt file if you don't want remove this....i am giving this to check result..

then /s for searching file including sub folders in your path...
here path is e:

you have write code for what you search and create string
like DIR /s e:\*.gif this

when you found record move image to your destination folder
Hope it helps you...
Last edited by Aamit; Dec 22nd, 2008 at 3:44 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: could i search images in a folder using php in offline

 
0
  #5
Dec 23rd, 2008
Hi Aamit,
I am trying your code but it displays some warning like 'system() function facing a security problem'. So i cant get the result.
Next, i am working in a networked system. Just i want to search all the images in the H: drive. What i am exactly trying to say is, i want a search program exactly as 'istockphoto.com' of my own. Could you tell me this is possible for writing code in php.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: could i search images in a folder using php in offline

 
0
  #6
Dec 23rd, 2008
first check on command prompt :- DIR /s h:\*.gif>>out.txt
if not working that means you don't have authority to use cmd ...
so first make user i.e you to User Account doesn't have admin privileges check for that....on google how to get admin privileges

In istockphoto.com i think they are using ajax +database whenever you type some text it gives you the category for that ..
so you have to create database & manage it using
php+ mysql+ ajax
search for ajax you got the lots of image example for it...
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: manish.s is an unknown quantity at this point 
Solved Threads: 1
manish.s manish.s is offline Offline
Newbie Poster

Re: could i search images in a folder using php in offline

 
0
  #7
Dec 23rd, 2008
<?php

function isImage($fileName)
{
	$ext = substr(strrchr($fileName, '.'), 1);	
	
	if($ext <> "")
	{
		$ext = strtolower($ext);
		switch($ext)
		{
			case 'gif': return true;
			case 'jpeg': return true;
			case 'png': return true;
			case 'psd': return true;
			case 'bmp': return true;
			case 'tiff': return true;
			case 'jp2': return true;
			case 'iff': return true;
			case 'ico': return true;
			default: return false;
		}
	}
	else
		 return false;
	
}

function ListMyFiles($dir,$MySearchFile) 
{
	    if($dh = opendir($dir)) 
	   {
		$files = Array();
		$inner_files = Array();

		while($file = readdir($dh)) 
		{
			    if($file != "." && $file != ".." && $file[0] != '.') 
			    {
					if(is_dir($dir . "/" . $file)) 
					{
						
					    $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
					    if(is_array($inner_files)) 
						$files = array_merge($files, $inner_files); 
					    
					} 
					else 
					{
						
						if($MySearchFile == "")
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
						else if ( strstr( $file,$MySearchFile ) )
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
					}
			    }
		}

		closedir($dh);
		return $files;
	    }
}


//NOTE : if u don't want to search by keywords plesae keep this field blank
$MySearchFile = "test";

foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
{
    
    echo "<br>".$file_name;
    
}  

?>
-- Manish Singh
manish.s@neuralit.com
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: could i search images in a folder using php in offline

 
0
  #8
Dec 24th, 2008
Originally Posted by manish.s View Post
<?php

function isImage($fileName)
{
	$ext = substr(strrchr($fileName, '.'), 1);	
	
	if($ext <> "")
	{
		$ext = strtolower($ext);
		switch($ext)
		{
			case 'gif': return true;
			case 'jpeg': return true;
			case 'png': return true;
			case 'psd': return true;
			case 'bmp': return true;
			case 'tiff': return true;
			case 'jp2': return true;
			case 'iff': return true;
			case 'ico': return true;
			default: return false;
		}
	}
	else
		 return false;
	
}

function ListMyFiles($dir,$MySearchFile) 
{
	    if($dh = opendir($dir)) 
	   {
		$files = Array();
		$inner_files = Array();

		while($file = readdir($dh)) 
		{
			    if($file != "." && $file != ".." && $file[0] != '.') 
			    {
					if(is_dir($dir . "/" . $file)) 
					{
						
					    $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
					    if(is_array($inner_files)) 
						$files = array_merge($files, $inner_files); 
					    
					} 
					else 
					{
						
						if($MySearchFile == "")
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
						else if ( strstr( $file,$MySearchFile ) )
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
					}
			    }
		}

		closedir($dh);
		return $files;
	    }
}


//NOTE : if u don't want to search by keywords plesae keep this field blank
$MySearchFile = "test";

foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
{
    
    echo "<br>".$file_name;
    
}  

?>

Hi,
I am still facing the problem. Error in opendir(). failed to open dir
opendir command does not support anway.
Pl anybody help me?

Ya! Its working but it dispalys only the filename like 001.jpg, 002.gif, 003.png etc.

But i want the image to display not the filename. Just like image search in google. could anybody help me???????????
Last edited by ashafaaiz; Dec 24th, 2008 at 5:30 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: manish.s is an unknown quantity at this point 
Solved Threads: 1
manish.s manish.s is offline Offline
Newbie Poster

Re: could i search images in a folder using php in offline

 
0
  #9
Dec 24th, 2008
try this code....
$cnt = 1;
$number_of_image_per_row = 6;
$width = 50; //Define image width
$height = 50 //Define image height

foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
{
      if($cnt % $number_of_image_per_row == 0)
	      echo "<br>";
      
	echo "<image src='".$file_name."'  $width $height >";
      
      $cnt++;
    
}
Last edited by manish.s; Dec 24th, 2008 at 8:35 am.
-- Manish Singh
manish.s@neuralit.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC