-Original Message-
From: Per Jessen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2008 1:43 AM
To: php-general@lists.php.net
Subject: Re: [PHP] file_exists and wildcard/regex
Ashley Sheridan wrote:
If you're on a Linux system, you could look at ls and the regular
-Original Message-
From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2008 8:28 AM
To: php-general@lists.php.net
Subject: RE: Re: [PHP] file_exists and wildcard/regex
FWIW, I would probably do the file search like this (UNTESTED):
?php
$filereg
On 9 Dec 2008, at 22:26, Daniel Kolbo wrote:
What is the preferred method with php to test and see if a file
[pattern] exists?
For example, i only need to search in one directory, that may have
any number of files named such as afile1.txt, afile2.txt,
afile3.txt, And also,
Daniel Kolbo wrote:
What is the preferred method with php to test and see if a file
[pattern] exists?
For example, i only need to search in one directory, that may have any
number of files named such as afile1.txt, afile2.txt, afile3.txt,
And also, bfile1.txt, bfile2.txt, bfile3.txt,
On Tue, 2008-12-09 at 12:54 -1000, Daniel Kolbo wrote:
Daniel Kolbo wrote:
What is the preferred method with php to test and see if a file
[pattern] exists?
For example, i only need to search in one directory, that may have any
number of files named such as afile1.txt, afile2.txt,
I'm not sure how glob works in the guts, but I know it is dog-slow for large
numbers of files (or maybe just large numbers of results).
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[EMAIL PROTECTED] wrote:
I'm not sure how glob works in the guts, but I know it is dog-slow for
large numbers of files (or maybe just large numbers of results).
I'm not sure what the context of this was, but the speed of searching a
directory with a large number of files, e.g. 100,000s,
Ashley Sheridan wrote:
If you're on a Linux system, you could look at ls and the regular
expressions it lets you use with it. You could exec out and get the
returned results. Also, as it's a system call, it should be very
speedy.
'ls' is just a plain binary (/bin/ls), not a system call. The
Stan wrote:
If $basePicture = ../pictures/2008 west coast trip/2008-06-10 first week at
Chris'/DSC_0011.jpg
and the file actually is ../pictures/2008 west coast trip/2008-06-10 first
week at Chris'/DSC_0011.JPG
(uppercase extension) the following snippet of code
On Sun, 2008-11-23 at 12:24 -0500, Craige Leeder wrote:
Stan wrote:
If $basePicture = ../pictures/2008 west coast trip/2008-06-10 first week at
Chris'/DSC_0011.jpg
and the file actually is ../pictures/2008 west coast trip/2008-06-10 first
week at Chris'/DSC_0011.JPG
(uppercase
Stan wrote:
The script is running on an UBUNTU v8.04 LAMP server. Case is
supposed to matter, isn't it?
out of interest try putting clearstatcache() before
if(!file_Exists($basePicture))
ps.. sure it should be file_exists all lowercase - perhaps you're
choosing to use call the function
Chris Haensel wrote:
Good morning list,
I have a _very_ simple function... it is as follows
/**/
function getgalimage($fzg) {
$folder = bilder;
$imgname= $fzg._1.JPG;
$checkimg =
Chris schrieb:
Chris Haensel wrote:
Good morning list,
I have a _very_ simple function... it is as follows
/**/
function getgalimage($fzg) {
$folder=bilder;
$imgname=$fzg._1.JPG;
$checkimg=$folder./.$imgname;
That worked like a charm. Now, can you tell me why that exact same function
works with a relative path on another server and with a full path only on
this server? I am glad that it works, but would also like to understand why
:o)
Could be different document roots for apache, different
Chris Haensel wrote:
That worked like a charm. Now, can you tell me why that exact same
function works with a relative path on another server and with a full
path only on this server? I am glad that it works, but would also
like to understand why
Check the working directory as well as the
-:- -Original Message-
-:- From: Chris [mailto:[EMAIL PROTECTED]
-:- Sent: Monday, August 25, 2008 9:25 AM
-:- To: Chris Haensel
-:- Cc: php-general@lists.php.net
-:- Subject: Re: [PHP] file_exists() not working correctly?
-:-
-:- Chris Haensel wrote:
-:- Good morning list
-:- -Original Message-
-:- From: Chris [mailto:[EMAIL PROTECTED]
-:- Sent: Monday, August 25, 2008 9:49 AM
-:- To: Chris Haensel
-:- Cc: php-general@lists.php.net
-:- Subject: Re: [PHP] file_exists() not working correctly?
-:-
-:-
-:- That worked like a charm. Now, can you tell
tedd wrote:
At 11:06 PM + 11/15/07, Stut wrote:
The realpath function will reduce your definition of $page to
/home/evil-user-home-dir/evil-payload.php
$expecteddir is set to /home/stut/phpstuff/inc
The if takes the first strlen($expecteddir) characters of the reduced
$page and compares
At 2:45 PM + 11/16/07, Stut wrote:
It also worth noting that what you're doing there is quite
inefficient. I have a similar arrangement where I have a directory
containing the include files, but I locate it in a different way.
Most sites I deal with have an auto-prepended file containing
At 11:06 PM + 11/15/07, Stut wrote:
The realpath function will reduce your definition of $page to
/home/evil-user-home-dir/evil-payload.php
$expecteddir is set to /home/stut/phpstuff/inc
The if takes the first strlen($expecteddir) characters of the
reduced $page and compares it to
Instruct ICC wrote:
Date: Thu, 15 Nov 2007 00:20:52 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Subject: Re: [PHP] file_exists
Philip Thompson wrote:
I've run into similar problems where I *thought* I was looking in the
correct location... but I wasn't
On Nov 15, 2007 7:16 AM, Stut [EMAIL PROTECTED] wrote:
Instruct ICC wrote:
Date: Thu, 15 Nov 2007 00:20:52 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Subject: Re: [PHP] file_exists
Philip Thompson wrote:
I've run into similar problems
Date: Thu, 15 Nov 2007 13:16:46 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Subject: Re: [PHP] file_exists
Instruct ICC wrote:
Date: Thu, 15 Nov 2007 00:20:52 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general
No, you've missed the point. $expecteddir is a fixed variable that you,
the script author, specify. It does not contain anything coming from
external veriables. You then compare the full path you build from the
external variables to $expecteddir to verify that the file is in the
Instruct ICC wrote:
No, you've missed the point. $expecteddir is a fixed variable that you,
the script author, specify. It does not contain anything coming from
external veriables. You then compare the full path you build from the
external variables to $expecteddir to verify that the file is
Instruct ICC wrote:
Date: Thu, 15 Nov 2007 13:16:46 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Subject: Re: [PHP] file_exists
Instruct ICC wrote:
Date: Thu, 15 Nov 2007 00:20:52 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general
My server is down right now so I can't do my usual example script.
A likely story.
Just kidding.
Stut, YOU WERE RIGHT, AND I WAS WRONG.
Your code is golden.
_
Help yourself to FREE treats served up daily at the Messenger Café.
Something like the following would be much better (untested)...
$page = realpath(dirname(__FILE__).'/inc/'.$_GET['page'].'.php');
$expecteddir = realpath(dirname(__FILE__).'/inc');
if (substr($page, 0, strlen($expecteddir)) != $expecteddir)
{
// Ideally return a 403 status here
Instruct ICC wrote:
Something like the following would be much better (untested)...
$page = realpath(dirname(__FILE__).'/inc/'.$_GET['page'].'.php');
$expecteddir = realpath(dirname(__FILE__).'/inc');
if (substr($page, 0, strlen($expecteddir)) != $expecteddir)
{
// Ideally return a 403
Chris wrote:
Ronald Wiplinger wrote:
I am having troubles with the function file_exists()
I tried the full path like:
if (file_exists('/srv/www/../images/pic412.jpg') {
echo IMG SRC='images/pic412.jpg';
} else {
echo nbsp; //picture is missing!
}
No
Ronald Wiplinger wrote:
Chris wrote:
Ronald Wiplinger wrote:
I am having troubles with the function file_exists()
I tried the full path like:
if (file_exists('/srv/www/../images/pic412.jpg') {
echo IMG SRC='images/pic412.jpg';
} else {
echo nbsp; //picture
On Nov 14, 2007 5:04 PM, Chris [EMAIL PROTECTED] wrote:
Ronald Wiplinger wrote:
Chris wrote:
Ronald Wiplinger wrote:
I am having troubles with the function file_exists()
I tried the full path like:
if (file_exists('/srv/www/../images/pic412.jpg') {
echo IMG
if (file_exists('/srv/www/../images/pic412.jpg') {
Two left parens, one right, surprised you don't get a syntax error?
Warren Vail
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Philip Thompson wrote:
I've run into similar problems where I *thought* I was looking in the
correct location... but I wasn't. Take this for example
?php // index.php?page=hello/hi
$page = $_GET['page'];
if (file_exists ($page.php)) {
include ($page.php);
}
?
I really hope this is not
Date: Thu, 15 Nov 2007 00:20:52 +
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Subject: Re: [PHP] file_exists
Philip Thompson wrote:
I've run into similar problems where I *thought* I was looking in the
correct location... but I wasn't. Take
Stut wrote:
Philip Thompson wrote:
I've run into similar problems where I *thought* I was looking in the
correct location... but I wasn't. Take this for example
?php // index.php?page=hello/hi
$page = $_GET['page'];
if (file_exists ($page.php)) {
include ($page.php);
}
?
I
Instruct ICC wrote:
Called like this?
index.php?page=http://evil-hacker-site.com/evil-payload.php
And the browser will probably url_encode for me if needed.
_
Climb to the top of the charts! Play Star Shuffle: the word
Ronald Wiplinger wrote:
Stut wrote:
Philip Thompson wrote:
I've run into similar problems where I *thought* I was looking in the
correct location... but I wasn't. Take this for example
?php // index.php?page=hello/hi
$page = $_GET['page'];
if (file_exists ($page.php)) {
Ronald Wiplinger wrote:
I am having troubles with the function file_exists()
I tried the full path like:
you are missing a closing parenthesis on your condition
if (file_exists('/srv/www/../images/pic412.jpg') ) {
if (file_exists('/srv/www/../images/pic412.jpg') {
echo IMG
Ronald Wiplinger wrote:
I am having troubles with the function file_exists()
I tried the full path like:
if (file_exists('/srv/www/../images/pic412.jpg') {
echo IMG SRC='images/pic412.jpg';
} else {
echo nbsp; //picture is missing!
}
No matter if I use the
On 10/24/07, Jim Lucas [EMAIL PROTECTED] wrote:
Daniel Brown wrote:
On 10/24/07, Manuel Vacelet [EMAIL PROTECTED] wrote:
Hi all,
file_exists and is_readable perfom there test with real UID/GID.
Is there any functions that tests file existance with effective UID/GID ?
Note: stat is
On 10/24/07, Manuel Vacelet [EMAIL PROTECTED] wrote:
Hi all,
file_exists and is_readable perfom there test with real UID/GID.
Is there any functions that tests file existance with effective UID/GID ?
Note: stat is not an option because it raises an E_WARNING if the file
is not readable.
Daniel Brown wrote:
On 10/24/07, Manuel Vacelet [EMAIL PROTECTED] wrote:
Hi all,
file_exists and is_readable perfom there test with real UID/GID.
Is there any functions that tests file existance with effective UID/GID ?
Note: stat is not an option because it raises an E_WARNING if the file
is
On Jun 18, 2007, at 3:30 PM, Myron Turner wrote:
I've written a plugin for DokuWiki which uses the following
DokuWiki function for reading files:
function io_readFile($file,$clean=true){
$ret = '';
if(@file_exists($file)){
if(substr($file,-3) == '.gz'){
$ret =
Edward Vermillion wrote:
On Jun 18, 2007, at 3:30 PM, Myron Turner wrote:
I've written a plugin for DokuWiki which uses the following DokuWiki
function for reading files:
function io_readFile($file,$clean=true){
$ret = '';
if(@file_exists($file)){
if(substr($file,-3) == '.gz'){
$ret =
Myron Turner wrote:
I've written a plugin for DokuWiki which uses the following DokuWiki
function for reading files:
function io_readFile($file,$clean=true){
$ret = '';
if(@file_exists($file)){
if(substr($file,-3) == '.gz'){
$ret = join('',gzfile($file));
On 6/18/07, Jim Lucas [EMAIL PROTECTED] wrote:
First off, don't jack someone else's thread.
Am I not getting all of the list messages today? I didn't see
where the thread hijacking occurred
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
--
PHP General
Jim Lucas wrote:
First off, don't jack someone else's thread.
Secondly, I think it might have something to do with the space in the
file name.
Try changing all spaces to %20 and see what happens.
$string = str_replace(' ', '%20', $string);
should do the trick
--
Jim Lucas
Some men
Daniel Brown wrote:
On 6/18/07, Jim Lucas [EMAIL PROTECTED] wrote:
First off, don't jack someone else's thread.
Am I not getting all of the list messages today? I didn't see
where the thread hijacking occurred
--
Jim Lucas
Some men are born to greatness, some achieve
On 6/18/07, Jim Lucas [EMAIL PROTECTED] wrote:
Daniel Brown wrote:
On 6/18/07, Jim Lucas [EMAIL PROTECTED] wrote:
First off, don't jack someone else's thread.
Am I not getting all of the list messages today? I didn't see
where the thread hijacking occurred
--
Jim Lucas
Some
On 17/06/06, Richard Lynch [EMAIL PROTECTED] wrote:
I dunno if AJAX will let you quit partway through, but you could
definitely do this with the lean and mean hand-coded XmlHttpRequest
object and sending HEAD to see if the URL is there or not.
For security reasons, an XMLHttpRequest objects
At 7:57 AM +0100 6/16/06, George Pitcher wrote:
Hi,
I have several websites that are using a common set of pages (to reduce
maintenance, development and upgrading) and use configuration files to give
the customer the feeling that it is their own unique site. The customers are
all universities and
I dunno if AJAX will let you quit partway through, but you could
definitely do this with the lean and mean hand-coded XmlHttpRequest
object and sending HEAD to see if the URL is there or not.
It will fail, of course, if they run this app from home or anything
not behind the firewall.
On Fri,
[snip]
I would like to use the file_exists() or something similar to check for
the
existance of any of the xml files regardless of what filename it use.
Like
file_exist(*.xml) for example. Anyone know??
[/snip]
Nope, no wildcard. You can only check for a specific file.
--
PHP General
Scott Fletcher wrote:
I would like to use the file_exists() or something similar to check for the
existance of any of the xml files regardless of what filename it use. Like
file_exist(*.xml) for example. Anyone know??
Try glob()
--
---John Holmes...
Amazon Wishlist:
I would like to use the file_exists() or something similar to check for the
existance of any of the xml files regardless of what filename it use. Like
file_exist(*.xml) for example. Anyone know??
You may use glob(),
http://www.php.net/glob
Regards,
Philip
--
PHP General Mailing
I would like to use the file_exists() or something similar to check for the
existance of any of the xml files regardless of what filename it use. Like
file_exist(*.xml) for example. Anyone know??
http://us3.php.net/readdir
?php
if ($handle = opendir('/path/to/files')) {
while
I like this one, the readdir() function. It look very promising.
Thanks!
Scott F.
Matt M. [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I would like to use the file_exists() or something similar to check for
the
existance of any of the xml files regardless of what filename it
Steve Magruder - WebCommons.org wrote:
File_exists results (and the results from other file-related functions) are
cached (according to the php doc) during the run of a script. For instance,
if file_exists returns True for a file once, it won't actually test the file
again if file_exists is run
Marek Kilimajer wrote:
Steve Magruder - WebCommons.org wrote:
File_exists results (and the results from other file-related
functions) are cached (according to the php doc) during the run of a
script. For instance, if file_exists returns True for a file once,
it won't actually test the file
On Tuesday 30 September 2003 19:00, [EMAIL PROTECTED] wrote:
I'm referencing an image on a different server, and it keeps changing
URL's
Very odd, but t get round that, I tried...
if (file_exists(http://www.othersite.com/image_1.gif;)) {
RTFM?
(Sorry, very newbie question)
Jason Wong [EMAIL PROTECTED]
30/09/2003 12:26
Please respond to
[EMAIL PROTECTED]
To
[EMAIL PROTECTED]
cc
Subject
Re: [PHP] file_exists on different server...
On Tuesday 30 September 2003 19:00, [EMAIL PROTECTED] wrote:
I'm referencing an image
Tristan --
...and then [EMAIL PROTECTED] said...
%
% RTFM?
% (Sorry, very newbie question)
Sort of, yes :-)
See The Jargon File at
http://catb.org/esr/jargon/
or jump straight to How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html
for not only a
what does $annrow[id] return?
I HAVE found that I have to refer to a file when using file_exists() from /
so
file_exists(/path/to/me/cherpdocs/filename.doc)
for it to work right.
Jim
- Original Message -
From: Charles Kline [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, March
because you can't directly use the $annrow[id] within single quotes, you
should use double quotes to do so.
file_exists(cherpdocs/$annrow[id].doc)
or
file_exists('cherpdocs/'.$annrow[id].'.doc')
or
file_exists(cherpdocs/.$annrow[id]..doc)
Note: i heared it's prefered to always use the .
You will probably need to use
file_exists(cherpdocs/{$annrow['id']}.doc) you could also use
file_exists('cherpdocs/' . $annrow['id'] . '.doc')
You should use single quotes to identify your element in an array,
otherwise PHP will try to use it as a constant first.
Jason
On Sat, 2003-03-08 at
At 22:40 08.03.2003, Khalid El-Kary said:
[snip]
because you can't directly use the $annrow[id] within single quotes, you
should use double quotes to do so.
file_exists(cherpdocs/$annrow[id].doc)
or
file_exists('cherpdocs/'.$annrow[id].'.doc')
or
on 09/03/03 8:10 AM, Charles Kline ([EMAIL PROTECTED]) wrote:
if(file_exists('cherpdocs/$annrow[id].doc')){
echo br /a href=\cherpdocs/$annrow[id].doc\Funding
details paper/a;
}
This is a pretty simple debugging type query, so:
First things first, make sure that $annrow[id] is what you
You're right - the example is wrong.
Neil
Anthony Ritter wrote:
**
This Message Was Virus Checked With : SAVI 3.58 May 2002
Last Updated 14th June 2002
On 6 May 2002 at 20:30, Craig Westerman wrote:
File is on another server. Is there a way to check if file exists on
another server?
I wrote the following function a while ago to do this. It works with http URLs and
should also
work with https and ftp, but I have only tested http. I hope it's
I found my problem.
From manual:
file_exists() will not work on remote files; the file to be examined must
be accessible via the server's filesystem.
File is on another server. Is there a way to check if file exists on another
server?
Craig
[EMAIL PROTECTED]
-Original Message-
Craig Westerman wrote:
I found my problem.
Try fopen() if it fails it will return false, otherwise it will return
an integer file pointer. You get use it to fetch files via http://,
https://, ftp://, and more.
From manual:
file_exists() will not work on remote files; the file to be
Does fopen() actually work for https connections? I thought this
implementation was not yet released.
-Original Message-
From: Austin Marshall [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 9:40 PM
To: Craig Westerman
Cc: php-general-list
Subject: Re: [PHP] file_exists
On Mon, 6 May 2002, Craig Westerman wrote:
What am I doing wrong? I get parse error between first echo statement and
else.
?php
$fn = image.gif;
if (!file_exists($fn)) {
echo img src=noimageexists.gif;
else
echo img src=$fn;
}
?
You open the brace for the positive branch of the if
Westerman
Cc: php-general-list
Subject: Re: [PHP] file_exists
Craig Westerman wrote:
I found my problem.
Try fopen() if it fails it will return false,
otherwise it will return
an integer file pointer. You get use it to fetch
files via http://,
https://, ftp://, and more
I've since tried that also. It too seems to return the same error. I'm
curious if the file_exists can't use relative positionslike it has to be
in the same folder or you have to use the whole line like c:\ I'm
working on a box that isn't mine of the net...if that's the case I don't
Hello Prolog,
Hm... And what about:
print 'img src=/images/$filename';
instead of readfile?
P if(file_exists(/images/$filename))
P {
P readfile(/images/$filename);
P }
P else
P {
P readfile(images/npat.jpg);
P }
Ivan 'Faeton aka
As documented: http://php.net/clearstatcache
-Rasmus
On Mon, 6 Aug 2001, Ken Williams wrote:
Am I an idiot?
(View this message as text)
html
body
?
$bIsFileOne = is_file(/tmp/test.txt); # Will be true cause test.txt will
exist
sleep (5); # Sleep while you telnet in and remove
On Tue, Apr 24, 2001 at 12:20:01AM -0300, Paulo - Bruc Internet wrote:
Can anyone help me?
The sintax of function file_exists is:
if(file_exists(t.txt))
{
print...
}
Does anybody knows how can work with remote files?
This is not working:
Gerry,
the following is your problem:
you fetch a row from the query result in each iteration:
while ($row = mysql_fetch_array($sql_result)) {
and the use the value of $ID.
$fn = "/images/$ID.jpg";
you need to fetch the value of the ID column into the ID variable
before. Assuming your select
Gerry,
could you give us a bit more code, esp. the while or for loop that
surrounds the code you have quoted?
Cheers,
Ben
Gerry wrote:
Hello everyone:
I'm trying to build a table with the last row being a check function for
an image, where it checks if the item image exists in the
Hello again:
Ben Peter wrote:
Gerry,
could you give us a bit more code, esp. the while or for loop that
surrounds the code you have quoted?
Cheers,
Ben
Sorry for the confusion, and yes I did mispelled camera in english. Here
is more of my sloppy code. I might have an extra }...not
It doesn't. Some of the file-related functions have that capability and some don't.
This may be what you're looking for:
function file_exists_in_path($file) {
foreach(split(':', ini_get('include_path')) as $dir) {
if ($dir[sizeof($dir)-1] != '/') {
83 matches
Mail list logo