May 23, 2012, 02:12:13 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Mobile users - Our forum is Tapatalk enabled.
http://www.tapatalk.com/
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
PHP Check if file exists
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: PHP Check if file exists (Read 1339 times)
Jeep Stone
Hero Member
Posts: 908
PHP Check if file exists
«
on:
June 25, 2007, 01:21:28 PM »
I want to check if an image file exists on the server. I've got an absolute URL so can't use file_exists because of security restrictions. What's the best way around this?
Logged
Jeepstone
Tanthalas
Hero Member
Posts: 1019
Re: PHP Check if file exists
«
Reply #1 on:
June 25, 2007, 01:44:29 PM »
Code:
if (! @fopen($filename, "r")) {
echo("You're having a laugh");
}
?
Logged
Aperture Science
We do what we must because we can
For the good of all of us, except the ones who are dead.
But there's no sense crying over every mistake
You just keep on trying 'til you run out of cake
And the science gets done, and you make a neat gun
For the people who are still alive
JasonD
Global Moderator
Hero Member
Posts: 546
Re: PHP Check if file exists
«
Reply #2 on:
June 25, 2007, 01:51:28 PM »
Huh? If you've got an absolute URL you can't use it because the http stream doesn't support stat(), not because of any security restrictions.
$parts = parse_url($your_absolute_url);
file_exists($_SERVER['DOCUMENT_ROOT'] . $parts['path'])
Assuming that is "the server" means the server, and not another server.
Logged
Jeep Stone
Hero Member
Posts: 908
Re: PHP Check if file exists
«
Reply #3 on:
June 25, 2007, 02:15:14 PM »
Cheers Jason.
Logged
Jeepstone
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
PHP Check if file exists
Loading...