473,888 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is_file() returns false for uploaded files?

Running IIS 6 on Windows 2003 server.

After an update to the most recent version of php 5.1.2, for some reacon
a function handling uploaded files using is_file stopped working. is_file
failed for existing files. I fixed it by changing is_file to
file_exists, then it worked again. Prior to the update, in the older
version, presumably it was 5.0.1, is_file worked just fine without
problems.

<?php
echo 'is_file:' . (is_file($_FILE S['myfile']['tmp_name']) ? 'true' :
'false');
echo 'file_exists:' . (file_exists($_ FILES['myfile']['tmp_name']) ? 'true' :
'false');
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>"
enctype="multip art/form-data" method="post">
<input type="file" name="myfile" />
<input type="submit" />
</form>

Submitted a bug report already http://bugs.php.net/bug.php?id=37118 but if
someone has any ideas what's going on here please reply.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Apr 18 '06 #1
6 4339
On Tue, 18 Apr 2006 12:54:08 +0300, Kimmo Laine wrote:
Running IIS 6 on Windows 2003 server.

After an update to the most recent version of php 5.1.2, for some reacon a
function handling uploaded files using is_file stopped working. is_file
failed for existing files. I fixed it by changing is_file to file_exists,
then it worked again. Prior to the update, in the older version,
presumably it was 5.0.1, is_file worked just fine without problems.

<?php
echo 'is_file:' . (is_file($_FILE S['myfile']['tmp_name']) ? 'true' :
'false');
echo 'file_exists:' . (file_exists($_ FILES['myfile']['tmp_name']) ? 'true'
: 'false');
?>


For this use, shouldn't you be using is_uploaded_fil e anyway?

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Apr 18 '06 #2
"Andy Jeffries" <ne**@andyjeffr ies.co.uk> wrote in message
news:pa******** *************** *****@andyjeffr ies.co.uk...
On Tue, 18 Apr 2006 12:54:08 +0300, Kimmo Laine wrote:
Running IIS 6 on Windows 2003 server.

After an update to the most recent version of php 5.1.2, for some reacon
a
function handling uploaded files using is_file stopped working. is_file
failed for existing files. I fixed it by changing is_file to file_exists,
then it worked again. Prior to the update, in the older version,
presumably it was 5.0.1, is_file worked just fine without problems.

<?php
echo 'is_file:' . (is_file($_FILE S['myfile']['tmp_name']) ? 'true' :
'false');
echo 'file_exists:' . (file_exists($_ FILES['myfile']['tmp_name']) ?
'true'
: 'false');
?>


For this use, shouldn't you be using is_uploaded_fil e anyway?


Possibly so, but that does not remove the bug. It's a piece of code I've
done some years ago that has worked fine even though a it's not perfect.
Still I'd like to be able to get similar results with is_file and
file_exists regardless of the file being user upload or not.

If this is not a bug but a feature, I'd like to see it explained in the
manual just what it means. ATM, it says in the manual: "is_file -- Tells
whether the filename is a regular file". So, what IS a regular file? What's
the difference between file_exists and is_file because they return different
results. I don't get it. And what bothers me the most is that up to this
point is_file has returned true. Why change it?

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Apr 18 '06 #3
The uploaded file is stored in a temporary folder outside your usual
PHP `filesystem'.
IIS seems to deny direct access to this folder, so you have to stick to
PHP's special functions for handling file uploads.

is_file() checks for regular files and returns false on directories or
symlinks, while file_exists() returns true, if the file, link or
directory exists.

Apr 18 '06 #4
"milahu" <mi****@googlem ail.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...
The uploaded file is stored in a temporary folder outside your usual
PHP `filesystem'.
IIS seems to deny direct access to this folder, so you have to stick to
PHP's special functions for handling file uploads.

So now copy() is a special function? I use just copy to handle uploaded
files, in that particular script. I could fix it to use move_uploaded_f iles
but it works now. "If it works don't fix it." And IIS does not deny access
to it as I can access it with copy. I don't have to use
move_uploaded_f iles() if that is what you mean by special function.
is_file() checks for regular files and returns false on directories or
symlinks, while file_exists() returns true, if the file, link or
directory exists.


But an uploaded file is neither a symlink (windows filesystem has no
symlinks) nor a directory, it's just a normal file. Now what exactly is the
determination of a "regular file", if the uploaded file is not one?

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Apr 19 '06 #5
> So now copy() is a special function?
Yes, it's holy for usual files, but not for uploaded ones. Why do you
just dislike move_uploaded_f ile() that much? PHP is not always as
logical as one would like it to be...
But an uploaded file is neither a symlink [...]

Already tested with is_link()? Win / NTFS doesn't support symlinks, so
I guess Apache emulates 'em.

Apr 20 '06 #6
"milahu" <mi****@googlem ail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
So now copy() is a special function?

Yes, it's holy for usual files, but not for uploaded ones. Why do you
just dislike move_uploaded_f ile() that much? PHP is not always as
logical as one would like it to be...


Nothing. move_uploaded_f iles and copy are not the issue here, both work just
fine. The problem is that is_file does not recognize an uploaded file as a
file, while file_exists does and I'd like to know why.
But an uploaded file is neither a symlink [...]

Already tested with is_link()? Win / NTFS doesn't support symlinks, so
I guess Apache emulates 'em.


Nothing to do with Apache either, using IIS 6 as I already said in my first
post.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Apr 20 '06 #7

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

Similar topics

2
6155
by: Phil Powell | last post by:
Code snippet: if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) { $html .= $font . '<font color=cc0000><li>Could not open files in content folder</li></font></font><p>'; } else if ($hasCookie) { clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY DETERMINE FILE STATUS $html .= $font . 'Contents: <p>';
3
8914
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
48
30214
by: Skybuck Flying | last post by:
Hi, I came across this C code which I wanted to understand etc it looked like this: if (-1) etc It made me wonder what the result would be... true or false ? In C and Delphi
2
15514
by: CVerma | last post by:
I'm using an html input control (System.web.UI.HTMLControls.HTMLInputFile) to upload files such as msword, excel, jpg, and pdf. I have the encType property set in the form: encType="multipart/form-data" <INPUT id="UploadFile" type="file" name="UploadFile" runat="server"> Private Sub btnUploadFile_Click(ByVal sender As System.Object, ByVal e
5
2739
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
3
3758
by: peter | last post by:
I have a weird problem in some code I am writing. The user selects a number of files from a list and then can select an option which will rename the selected files. Before the process starts, a yes/no dialog box pops up just to confirm. Most of the time this works fine, but occasionally it seem the dialog box gets into a state where it always returns False, irrespective of the button clicked. I must be doing something wrong, but I...
14
2815
by: =?Utf-8?B?U2FtdWVs?= | last post by:
Hi, I have a web app that allows others to upload files, and the problem is that if I allow users to upload image files, fake image can be uploaded and cause XSS issues. In the app, I do check image dimension when uploaded so that any fake image that is actually a text file is blocked (user renames a .txt to .gif, e.g.). However, a png file renamed to .gif can contain script that when loaded
5
5430
by: Tyno Gendo | last post by:
How do you normally check filetypes? I ended up resorting to !is_dir($file) as all other calls seem to fail so I had to assume if not a directory its a file, rather than specifically checking if its a file. I'm recursing a folder: <?php $cat_seq = 1; $path = "e:\\videos\\$cat_seq"; $dh = opendir($path);
2
1388
by: Confused but working on it | last post by:
Thanks for the help with escaping that line. My gallery works great. Just lines up the pictures and if you resize they move with it instead of using tables. Added a class to pad each image and looks pretty clean. The code: <?php //Open images directory $dir = opendir("images"); //List files in images directory while (($file = readdir($dir)) !== false) {
0
9961
marktang
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...
0
9800
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,...
0
10777
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
7990
isladogs
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...
0
7148
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
5817
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...
1
4642
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
4243
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3251
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.