•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,511 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,116 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 330 | Replies: 14
![]() |
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 0
I can't seem to get the fopen thing to work, or otherwise, I'm just stupid if it is but I don't know it.
Here is the code:
If that should work, how would I be able to tell, or should I add something to see if it works.
Thanks
Here is the code:
php Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <HEAD> <title>Open the file</title> </HEAD> <body> <?php $fp = fopen("http://www.mydomain.org/order.txt", "a+"); fclose($fp); ?> </body> </html>
If that should work, how would I be able to tell, or should I add something to see if it works.
Thanks
php Syntax (Toggle Plain Text)
$fp = fopen("http://www.mydomain.org/order.txt", "a+"); if($fp){ echo "file opened"; } else{ echo "file did not open"; }
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 771
Reputation:
Rep Power: 2
Solved Threads: 63
This should answer your question
http://us3.php.net/manual/en/function.fread.php
http://us3.php.net/manual/en/function.fread.php
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.†- Dr. Seuss
Do you have access to the server? Your host may have the functions disabled. If you are not sure, place the following into a new php file and name it phpinfo.php: This page will output all of apaches settings. What you should look for is under PHP Core. The directive is named disable_functions. If fopen is disabled, it will be listed here. Just a thought.
php Syntax (Toggle Plain Text)
<?php phpinfo(); ?>
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 0
Do you mean this?
Directive Local Value Master Value
allow_url_fopen On On
Or this one:
disable_functions no value no value
And since I own that website, and since I can save other files to that folder, I'm pretty sure that I have access, or does it have to do with the folder permissions thing? The permissions code for the folder that I want to open the file in is "drwxr-xr-x".
Directive Local Value Master Value
allow_url_fopen On On
Or this one:
disable_functions no value no value
And since I own that website, and since I can save other files to that folder, I'm pretty sure that I have access, or does it have to do with the folder permissions thing? The permissions code for the folder that I want to open the file in is "drwxr-xr-x".
No, it was just a hunch. Can you test a local file? Create a text file, type a couple of words in it to give it some testable content and save it as testFile.txt in the same directory as your current script. Now run the following:
Note that the script checks filesize before attempting fread. You'll get an error attempting fread if the file is 0.
php Syntax (Toggle Plain Text)
<?php $file="testFile.txt"; $fp = fopen($file, "a+"); if($fp){ echo "file opened "; } else{ echo "file did not open "; } if(filesize($file)!=0) { $contents = fread($fp, filesize($file)); echo $contents; } else { echo "The file is empty"; } fclose($fp); ?>
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation:
Rep Power: 1
Solved Threads: 14
I believe you can only use a write mode such as 'a+' with fopen on a remote file if using ftp:// as the protocol...even so, you would have to have appropriate ftp permissions to write/append. More about that here:
http://us.php.net/manual/en/features.remote-files.php
http://us.php.net/manual/en/features.remote-files.php
The End
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Installing Windows 98 On VMware. Floppy problem (Windows 9x / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP / 2003)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Gadgets and Gizmos)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
- Problem with Windows Update and WinXP (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: PHP :
- Next Thread: permissions


Linear Mode