473,503 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic Filesize() call fails

I just CANNOT figure out what is wrong with this!

------

$op1f = fopen("./test.txt","r");
$op1 = fread($op1f, filesize($op1f));

------

my file text.txt is in the same dir as the php file. I get the
following errors on run:

------

Warning: filesize() [function.filesize]: stat failed for Resource id #3
in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

Warning: fread() [function.fread]: Length parameter must be greater
than 0. in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

------
I know it's something stupid I'm doing, but I simply can't figure it
out!

Thanks,
IWP506

Jul 17 '05 #1
2 11684
IW****@gmail.com wrote:
$op1f = fopen("./test.txt","r");
$op1 = fread($op1f, filesize($op1f));

Warning: filesize() [function.filesize]: stat failed for Resource id #3
in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

I know it's something stupid I'm doing, but I simply can't figure it
out!


Read the manual page (http://nl2.php.net/filesize) carefully, It's
contains the prototype of filesize():
int filesize ( string filename )

Thus the only argument to filesize should be a string containing the
name of the file. You error reports that the argument passed in your
script is a resource and thus not a string.

BTW you lack any errorhandling, so an other error will appear to the
user in case eg test.txt doesn't exist or is not readable...

Jul 17 '05 #2
I knew it was something stupid.

Thanks,

IWP506

Jul 17 '05 #3

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

Similar topics

1
1592
by: Charles | last post by:
Ok, I have an Access 97 GUI with SQL 7.0 backend. On one database I'm constantly getting a call fail. I'm not sure why. From the user accounts it seems to happen mostly when they have the form...
0
1049
by: BobJones | last post by:
After inserting the third CD during the installation process, the program starts rolling back the installation and displays an error message. I am running Windows 2000 SP4, installing VB.Net from...
0
2127
by: 220rounder | last post by:
Hi..Created a simple web service in MS Visual Studio 2005 on my dev laptop. I can access it fine on the laptop. I then created a web setup project and deployed it to an app server. I now get an...
5
3734
by: oliharvey | last post by:
hallo - I am making a web request (actually a web service call) from within my web service. this works fine under the developement web server - but fails under IIS with: anyone have any...
2
2286
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have the below C# definitions and function call to an unsafe C++/CLI function in an external dll. When debugging the calls step by step everything seems to work, but if I just run everything...
2
1052
by: ss0007 | last post by:
Hi everyone , I was testing the following piece of code and unable to proceed because the click() method is not invoked for the button's onclick event. The same function works fine in the...
2
8387
by: rdilipk | last post by:
I am posting at the end of this post some code that P/Invoke's SetSystemTime to set the local system time. This call fails -- i.e the time is not set and the API returns false. However calling...
2
8116
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
0
1736
by: Oscar Arreyano | last post by:
"jimbob" <nospam@virgingmedio.comwrote in message news:mq7ke45h9hti1fp0c8o693qqrg5kavqk4g@4ax.com... sprintf('%u', filesize($file));
0
7199
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,...
0
7076
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...
0
7274
Oralloy
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,...
0
7323
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...
1
6984
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...
0
7453
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...
0
3162
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...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
377
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...

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.