473,800 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file_exists() returns false

$file = 'C:\Documents and Settings\Michae l\Escritorio\El vis\test.txt';

file_exists($fi le)
and
file_exists('"' .$file.'"')

both return false although the file does exist on the user's machine.

What am I doing worng?

Kind regards,

Jan Nordgreen
Jun 27 '08 #1
9 2134
I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

Kind regards,

Jan Nordgreen
Jun 27 '08 #2
this can't be done (with php).
php is only running on the server without knowing things about the
visiter (apart from the things stored in $_SERVER) and can't affect
anything on the users filesystem.
if it could this would be a serious security problem. imagine i could
access every file on your harddisc just by making you visit my website.
Jun 27 '08 #3
On Wed, 4 Jun 2008 07:03:23 -0700 (PDT), damezumari wrote:
I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?
That'd be up to the possibly-faulty implementation of /Java(script)?/.

--
Crowds want to beat, journalists deserve to be beaten. Where lies
the problem?
-- Lars Syrstad
Jun 27 '08 #4
On 4 Jun, 15:03, damezumari <jannordgr...@g mail.comwrote:
I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

Kind regards,

Jan Nordgreen
How's about explaining WHY you think you need to do it, so that we can
try to help you to achieve your ultimate aim?
Jun 27 '08 #5
Peter H. Coffin wrote:
On Wed, 4 Jun 2008 07:03:23 -0700 (PDT), damezumari wrote:
>I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

That'd be up to the possibly-faulty implementation of /Java(script)?/.
Java (applets) can, I suspect Flash can too, javascript only if a
particular UA manufacturer has erred beyond believe.
--
Rik Wasmus
....spamrun finished
Jun 27 '08 #6
damezumari wrote:
I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

Kind regards,

Jan Nordgreen
No, you can't do it in PHP. You also can't do it in Javascript (unless
the browser is broken). To be able to do such would be a huge security
hole - allowing a hacker website to read any file on your computer.

You can do it with a Java applet, if the user configures Java to allow
such, but most people don't.

Which begs the question - what are you really trying to do? Maybe we
can suggest another way which will work.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 27 '08 #7
Rik Wasmus wrote:
Peter H. Coffin wrote:
>On Wed, 4 Jun 2008 07:03:23 -0700 (PDT), damezumari wrote:
>>I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

That'd be up to the possibly-faulty implementation of /Java(script)?/.

Java (applets) can, I suspect Flash can too, javascript only if a
particular UA manufacturer has erred beyond believe.
I'm curious. How does type="file" work? That allows a directory search
of the user's machine. Of course, it it totally under the user's
control, so no security breach, but what mechanism is used to get the data?
Jun 27 '08 #8
On Wed, 04 Jun 2008 18:40:33 +0200, sheldonlg <sheldonlgwrote :
Rik Wasmus wrote:
>Peter H. Coffin wrote:
>>On Wed, 4 Jun 2008 07:03:23 -0700 (PDT), damezumari wrote:
I have been told that file_exists() looks for files on the server, not
on the user's machine.

If that is correct the question then is: how do I check if a file
exist on the user's machine? Or can't it be done?

That'd be up to the possibly-faulty implementation of /Java(script)?/.
Java (applets) can, I suspect Flash can too, javascript only if a
particular UA manufacturer has erred beyond believe.

I'm curious. How does type="file" work? That allows a directory search
of the user's machine. Of course, it it totally under the user's
control, so no security breach, but what mechanism is used to get the
data?
It's outside the page, the file input element is not controllable in any
way. It's just the UA itself which can open file menu's, and interpret the
value to which it is set.
--
Rik Wasmus
....spamrun finished
Jun 27 '08 #9
Greetings, damezumari.
In reply to Your message dated Wednesday, June 4, 2008, 17:45:13,
$file = 'C:\Documents and Settings\Michae l\Escritorio\El vis\test.txt';
file_exists($fi le)
and
file_exists('"' .$file.'"')
both return false although the file does exist on the user's machine.
What am I doing worng?
You have remembered me one old joke.

"Hi, i'm <insert your preferred nationvirus.
We here in <inserted nationknow nothing about computers and programming, so
please, forward this letter to all your friends, then delete all your files from
your harddrive.
Thanks."
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>

Jun 27 '08 #10

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

Similar topics

0
4532
by: Chann Becker | last post by:
My current setup: WWW Server: Windows 2000 Server, SP4 IIS5 PHP 4.3.4 File Server Windows 2000 Server, SP4
2
3761
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")){
1
2285
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))
3
7972
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...
12
11891
by: Alan | last post by:
Running PHP5 with IIS on a Win2K Server whenever I try file_exists() on a file in a windows share on another server I get a response of False - I can't open the file or do anything with it. I'm sure the filename/path is Ok $filename= '//print-admin/Public$/planningprepress/planning/prepresslist.xls' I've tried replacing all the '/' with chr(92) to no avail. The only
6
2788
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 ?
2
1977
by: roger.moon2 | last post by:
So I wrote a script to run via crontab but when it tries to check whether a file exists like below: if (!file_exists("settings.ini")) return false; it checks whether the file exists in $HOME not in /home/user/files/ scripts/ where the original file is been executed from: 00 20 * * 1 /usr/local/bin/php /home/user/files/scripts/check.php /
15
9115
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)) { ...
5
13131
by: chromis | last post by:
Hi there, This has probably been asked a million times but having looked through the PHP manual for the file_exists() function I can't seem to get the right code for what I want to do. I have a typical scenario of wanting to check for an image files existence before displaying, I have foubd the following code to do this but it always returns false: $imageURL = "http://website.com/images/image1.jpg"; $handle =...
0
10279
jinu1996
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...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
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...
0
6815
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();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
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...

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.