472,950 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

search a web server directory

Hello All,

Please advice...I would like to do this in php, but I am open
to suggestions
I am going to place about 6 gigs of jpeg pictures on a web
server. And. I want to allow a user to go to a web page and type in
the name of a file, and if the file is found in the particular
directory on the server, the jpeg picuture will then be display in the
web browser.
I am thinking about just having a php script that will search
the particular directory, but I am not sure where to get started.
Also, will this bogg down the server.

And, in case anyone is wondering...this is being done for a
department at my university.
thanks,
Hostos
Jul 17 '05 #1
7 1856
Hostos wrote:
I want to allow a user to go to a web page and type in
the name of a file, and if the file is found in the particular
directory on the server, the jpeg picuture will then be display in the
web browser. I am thinking about just having a php script that will search
the particular directory, but I am not sure where to get started.
<?php
// this script is the action specified for the form that asks for the
// file name (or the same script that outputs the form
$filename = $_POST['filename'];
$directory = 'images/2003/';
if (isfile($directory . $filename)) {
echo '<img src="', $directory . $filename, '"/>';
} else {
echo '<p class="error">file ', $filename, ' does not exist in ',
$directory, '.</p>';
}
?>
Also, will this bogg down the server.


I don't know. If it does maybe it's better to check for filename in a
filelist text file generated automaticcaly (by a cron job?)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
"Hostos" <hm******@hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Hello All,

Please advice...I would like to do this in php, but I am open
to suggestions
I am going to place about 6 gigs of jpeg pictures on a web
server. And. I want to allow a user to go to a web page and type in
the name of a file, and if the file is found in the particular
directory on the server, the jpeg picuture will then be display in the
web browser.
I am thinking about just having a php script that will search
the particular directory, but I am not sure where to get started.
Also, will this bogg down the server.

And, in case anyone is wondering...this is being done for a
department at my university.
thanks,
Hostos


just a thought, but if its a linux platform you can try the locate command,
and pass through grep for the parent directory:

// find all house pictures
$searchString = "house";
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;

to update the locate db, type this on the command line:
updatedb

or wait untill the next day, it should be already in a cron job

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #3
CountScubula wrote:
just a thought, but if its a linux platform you can try the locate command,
and pass through grep for the parent directory:

// find all house pictures
$searchString = "house";
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;


Remember though that if the user is typing in $searchString - NEVER EVER
DO THE SECOND LINE SHOWN ABOVE!

If the user types "a; rm -f /some/file/here; locate a" as $searchString
it will delete the file (if Apache has permissions) and continue as if
nothing had happened....

Cheers,
Andy
Jul 17 '05 #4
"Andy Jeffries" <ne*****@seirffej.reverse.previous.word.co.uk> wrote in
message news:10***************@echo.uk.clara.net...
CountScubula wrote:
just a thought, but if its a linux platform you can try the locate command, and pass through grep for the parent directory:

// find all house pictures
$searchString = "house";
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;


Remember though that if the user is typing in $searchString - NEVER EVER
DO THE SECOND LINE SHOWN ABOVE!

If the user types "a; rm -f /some/file/here; locate a" as $searchString
it will delete the file (if Apache has permissions) and continue as if
nothing had happened....

Cheers,
Andy


True, but this was not meant to be a end all script snippet, however, I
should have seen that comming.

REVISED:

// find all house pictures
$searchString = "house";
$searchString = strtr($searchString,";./ ","----"); // andd chrs to remove,
as to keep safe
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #5
CountScubula wrote:
// find all house pictures
$searchString = "house";
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;


Remember though that if the user is typing in $searchString - NEVER EVER
DO THE SECOND LINE SHOWN ABOVE!

If the user types "a; rm -f /some/file/here; locate a" as $searchString
it will delete the file (if Apache has permissions) and continue as if
nothing had happened....


True, but this was not meant to be a end all script snippet, however, I
should have seen that comming.


I know you knew that Mike (we've had technical chats a few times IIRC)
but I thought it prudent for anyone finding the post through Google or
maybe the OP.

Cheers,
Andy
Jul 17 '05 #6
"Andy Jeffries" <an**@seirffej.reverse.previous.word.co.uk> wrote in message
news:10****************@ersa.uk.clara.net...
CountScubula wrote:
// find all house pictures
$searchString = "house";
$files = `locate $searchString | grep '/www/parent/dir/pictures/'`;

Remember though that if the user is typing in $searchString - NEVER EVER
DO THE SECOND LINE SHOWN ABOVE!

If the user types "a; rm -f /some/file/here; locate a" as $searchString
it will delete the file (if Apache has permissions) and continue as if
nothing had happened....


True, but this was not meant to be a end all script snippet, however, I
should have seen that comming.


I know you knew that Mike (we've had technical chats a few times IIRC)
but I thought it prudent for anyone finding the post through Google or
maybe the OP.

Cheers,
Andy


Hi Andy, I didn't take any offense to it, I totally agree with you. Funny
thing is, someone posted a piece of code and asked what was wrong, and I
went to thier site, and brough it down several times (with thier permission)
and exploited several things, from just such a type of thing.

Thanks for keeping me on my toes. :)

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #7
Uzytkownik "Pedro Graca" <he****@hotpop.com> napisal w wiadomosci
news:c2*************@ID-203069.news.uni-berlin.de...
Also, will this bogg down the server.


I don't know. If it does maybe it's better to check for filename in a
filelist text file generated automaticcaly (by a cron job?)


Or cache the list and do a mtime comparison between the file and the
directory. It probably takes longer though for PHP to find an item in an
array then for the file system to locate a file, since there isn't function
that performs binary search.
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alan | last post by:
I'm just about to start a project that needs to combine the results of a SQL Server query with the results of an Index Server query. The basic idea is that the user enters/selects a bunch of search...
3
by: Carol | last post by:
What's the best way to do a site search of my site? I am using asp and access heavily on a regular ISP google? Or write a bunch of queries? what else is there?
5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
6
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result...
5
by: Kaamp | last post by:
I am trying to create a simple AD search page where any of my co workers can input and name and get in return phone numbers. I don't need anything fancy, since most of the internal site has already...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
2
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server...
2
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server...
5
by: moorcroft | last post by:
Hi I have developed an application that people can use to search for planning applications. The way it works is that once search criteria has been selected and submit is hit, the server will save...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.