This is my code:
if (file_exists($F name)) {
echo "<td>$Fname exists</td>";
} else {
echo "<td>$Fname does not exist</td>";
}
$Fname is the full path to the file I'm trying to verify. When I run the
script, I get the following output: http://server1:8080/images/dwg_images/5005/5005001_.pdf does not exist
If I cut-and-paste the output path, the file is displayed, confirming that
the file does exist.
Am I doing something wrong? Any help will be greatly appreciated. 20 3669
On Mon, 13 Aug 2007 14:36:19 +0200, Bob Sanderson
<ne**@LUVSPAMbo bsanderson.comw rote:
This is my code:
if (file_exists($F name))
http://server1:8080/images/dwg_images/5005/5005001_.pdf does not
exist
From the manual:
File_exists:
<http://nl3.php.net/file_exists>:
"As of PHP 5.0.0 this function can also be used with some URL wrappers.
Refer to Appendix O, List of Supported Protocols/Wrappers for a listing of
which wrappers support stat() family of functionality."
HTTP wrapper:
<http://nl3.php.net/manual/en/wrappers.http.p hp>
Table O.2. Wrapper SummaryAttribut e Supported
Restricted by allow_url_fopen Yes
Allows Reading Yes
Allows Writing No
Allows Appending No
Allows Simultaneous Reading and Writing N/A
Supports stat() No <---------------------------
Supports unlink() No
Supports rename() No
Supports mkdir() No
Supports rmdir() No
Ergo: file_exists does not play nice with http:// wrappers. If you want to
verify wether an URL exists, use fsockopen()(HEA D request), or CURL.
--
Rik Wasmus
Rik <lu************ @hotmail.comwro te in
news:op.twzz8gz nqnv3q9@metalli um:
On Mon, 13 Aug 2007 14:36:19 +0200, Bob Sanderson
<ne**@LUVSPAMbo bsanderson.comw rote:
>This is my code:
if (file_exists($F name))
> http://server1:8080/images/dwg_images/5005/5005001_.pdf does not exist
From the manual:
File_exists:
<http://nl3.php.net/file_exists>:
"As of PHP 5.0.0 this function can also be used with some URL
wrappers. Refer to Appendix O, List of Supported Protocols/Wrappers
for a listing of which wrappers support stat() family of
functionality."
HTTP wrapper:
<http://nl3.php.net/manual/en/wrappers.http.p hp>
Table O.2. Wrapper SummaryAttribut e Supported
Restricted by allow_url_fopen Yes
Allows Reading Yes
Allows Writing No
Allows Appending No
Allows Simultaneous Reading and Writing N/A
Supports stat() No <---------------------------
Supports unlink() No
Supports rename() No
Supports mkdir() No
Supports rmdir() No
Ergo: file_exists does not play nice with http:// wrappers. If you
want to verify wether an URL exists, use fsockopen()(HEA D request),
or CURL.
Thanks for the reply but I'm a beginner with PHP and frankly, don't
understand any of what you said. Is there another, simple way to
determine if a file exists?
<comp.lang.ph p>
<Bob Sanderson>
<Mon, 13 Aug 2007 12:36:19 GMT>
<Xn************ *************** *******@69.28.1 86.158>
This is my code:
if (file_exists($F name)) {
echo "<td>$Fname exists</td>";
} else {
echo "<td>$Fname does not exist</td>";
}
$Fname is the full path to the file I'm trying to verify. When I run the
script, I get the following output:
http://server1:8080/images/dwg_images/5005/5005001_.pdf does not exist
If I cut-and-paste the output path, the file is displayed, confirming that
the file does exist.
As another user its best if you check the actual folder path rather than
a http url .
You can also write it like the below if you dont want to use else .
$pass=1;
$tempname="imag es/5005/5005001.pdf";
if (!file_exists($ tempname)) {$pass=0;}
if ($pass==0) {print "<td>$tempn ame FILE NOT FOUND</td>";}
if ($pass==1) {print "<td>$tempn ame OK</td>";}
On Mon, 13 Aug 2007 15:34:27 +0200, Krustov <me@privacy.net wrote:
$pass=1;
if (!file_exists($ tempname)) {$pass=0;}
if ($pass==0) //
if ($pass==1) //
Euhm,
if(file_exists( )){
//something
} else {
//something else
}
Keep it legible for other coders, limit the amount of random variables
popping up in your script if you don't need them, and avoid
double/repeated comparisons...
--
Rik Wasmus
On Mon, 13 Aug 2007 14:59:07 +0200, Bob Sanderson
<ne**@LUVSPAMbo bsanderson.comw rote:
Thanks for the reply but I'm a beginner with PHP and frankly, don't
understand any of what you said. Is there another, simple way to
determine if a file exists?
A 'file' is not the proper term for something accessed by the HTTP
protocol. As others have indicated, if the file is on the same server, you
should use the local filesystem instead of the long way around by http.
If it is on another server however, look at the user contributed notes at
<http://www.php.net/file_exists>, several options for determining wether
an URL can be 'found' are given there.
--
Rik Wasmus
<comp.lang.ph p>
<Rik>
<Mon, 13 Aug 2007 15:38:56 +0200>
<op.twz2u6xyqnv 3q9@metallium>
$pass=1;
if (!file_exists($ tempname)) {$pass=0;}
if ($pass==0) //
if ($pass==1) //
Euhm,
if(file_exists( )){
//something
} else {
//something else
}
Keep it legible for other coders, limit the amount of random variables
popping up in your script if you don't need them, and avoid
double/repeated comparisons...
Up your arse .
I dont recall asking you for your zen like wisdom on how i should or
shouldnt write code .
Rik <lu************ @hotmail.comwro te in news:op.twz2u6x yqnv3q9@metalli um:
On Mon, 13 Aug 2007 15:34:27 +0200, Krustov <me@privacy.net wrote:
>$pass=1; if (!file_exists($ tempname)) {$pass=0;} if ($pass==0) // if ($pass==1) //
Euhm,
if(file_exists( )){
//something
} else {
//something else
}
That did it. Thanks to all.
<comp.lang.ph p>
<Rik>
<Mon, 13 Aug 2007 16:36:30 +0200>
<op.twz5i4ikqnv 3q9@metallium>
Common mistake: there are very little rules, but as it is internet
No - its actually called usenet - and is merely a part of the internet .
Usenet doesnt have any heirarcial command structure and everybody is
equal with everybody having the same rights .
That is apart from people like yourself who self appoint themselves as
some sort of newsgroup arsehole who trys to dictate and decide what
other users can and cant say on 'their' newsgroup .
<comp.lang.ph p>
<Jerry Stuckle>
<Mon, 13 Aug 2007 10:58:22 -0400>
<8I************ *************** ***@comcast.com >
Rik is correct. When you post sample code, you should try to ensure it
is a good example
Who decides what is good or bad on this newsgroup - you and rik ? . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew Crowe |
last post by:
Hi guys,
I've created this little function to check whether a user has uploaded a
file with the same name as an existing file, and if so rename it to
file-1.jpg, file-2.jpg etc.
clearstatcache();
if(file_exists("$BasePath/$FileName.jpg")){
$extra=1;
while(file_exists("$BasePath/$FileName-$extra.jpg")){
|
by: Google Mike |
last post by:
{NOTE: I have PHP 4.2.2 for RH9 Linux.}
Anyone have a better file_exists() out there? Even if you use shell
out tricks with Linux using the `command` trick, I'd be interested to
see what you came up with.
I have this remotely mounted SMB shares on Linux, stuck in my /mnt
directory, and the docs tell me that file_exists() doesn't work on
that. When I tested this, I found this to be true. Therefore, I need
an alternative.
|
by: Hinrich Specht |
last post by:
Hello,
I have a problem using file_exists. I want to use file_exists to
dertermine if a product-image is available or not to show either the
product-image or a standard-image.
This is the code:
$image = "../../artimages/".$item_code.".jpg";
if (file_exists($image))
|
by: annie |
last post by:
Hi
I've got two linux boxes running redhat9 and either PHP Version 4.2.2
or PHP Version 4.3.7. The file structure is set up the same on both
machines and both files exist. The problem is not file specific and
on both machines seq_tables is a symbolic link to another location.
It makes no difference to either version of php whether I use double
or single quotes when asigning a value to $filename. Nor does it
matter whether I use...
|
by: lkrubner |
last post by:
I've written some template code and one thing I'm trying to protect
against is references to images that don't exist. Because users have
the ability to muck around with the templates after everything's been
set up, there is a chance they'll delete an image or ruin some tag
after the web designer has set up everything perfectly. I want the
software to catch mistakes like that and, at the very least, not show
broken links. On the control...
| |
by: dchaffin |
last post by:
I'm having a problem using file_exists with an absolute path and I can
not figure out why.
I tried the exact example that is on www.php.net ...
<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
|
by: +86 |
last post by:
i encountered this problem:
"include('inc.php')" will work problely
but "include('./inc.php') doesn't work ..
both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'
my environment is win2003+iis+php5
how to fix it ?
|
by: cooldht |
last post by:
Hi all,
I ran into a cool function in a google search, called file_exists that would do exactly what I need it to do. Unfortunately, I think something is wrong with the logic I'm using, because it returns a value of null instead of true or false. It seems to work great if I check for something in the base directory, but when I try something outside of the root, it fails. The check file code looks like this:
if (file_exists($filename)) {
...
|
by: rickcasey |
last post by:
I'm using PHP 4.4.4-8 on Debian Linux on a low traffic site, and need
to detect if a file exists, and if so, unlink it.
I am mystified as to why the file_exists() function does not work in
one particular section of code, yet does work in another section. The
unlink() function similarly works in one section, but not the other.
I have read other posts in this group where others have had trouble
with the file_exists() function, but none...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |