I was trying to set up some fopen function
$path = 'php://testdir';
$h = fopen($path, "rw+") or die("Error");
fwrite($h, "test");
fseek($h, 0);
echo stream_get_contents($h);
For some reason there's still an error. I've done following steps to fix this:
checked php.ini and switched on allow_url_fopen, save_mode + restarted apache
added even chmod 777 (that's test passwd protected server, so done it temporarily)
was even try to fopen some existing file in the same location but still getting an error
error_reporting doesn't show anything (when removed die statement to test) but logs are showing:
[error] [xxx] PHP Warning: fopen(): Invalid php:// URL specified in /var/www/xxx/xxx/all.php on line 24, referer: http://xxxxxxxxxx/xxxx/all.php
[error] [xxx] PHP Warning: fopen(php://testdir): failed to open stream: operation failed in /var/www/xxx/xxx/all.php on line 24, referer: http://xxxxx/xxxx/all.php
'xxx' changed by myself here.
That's not what php:// is for. It allows access to specialized streams such has stdin/stdout/etc, not regular file access.
Don't bother using php:// - your fopen() call should just have the path to the file. Something like fopen('/path/to/testfile.txt')
Related
I'm using Ubuntu 20.04.4 LTS, Apache/2.4.41, PHP 5.6.40-57.
When I call
error_log ('Page is not writable for save called)', 3, "/var/log/apache2/php_error.log");
there is nothing in /var/log/apache2/php_error.log.
php_error.log file is exist, and it is 777.
When I open /var/log/apache2/error.log, this error log was added.
PHP Warning: error_log(/var/log/apache2/error.log):
failed to open stream: \xed\x97\x88\xea\xb0\x80 \xea\xb1\xb0\xeb\xb6\x80 in /var/www/html/moniwiki/wiki.php on line 1258, referer: https:/
/myhome.ddns.net:9443/moniwiki/wiki.php?015B
why php_error.log is empty?
how am I able to change these \xed.. character to normal character?
what is \xed... and is there any website to decode these characters?
In my application I need to open one file to get the contents present in that.
for that I used file_get_contents()
$data = file_get_contents('/var/www/web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat');
But this causes an error
Severity: Warning --> file_get_contents(/var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat) [function.file-get-contents]: failed to open stream: No such file or directory
Why this error is occurring? how to fix this?
if the file actually exists then it is probably a rights/ownership issue.
$ chmod 775 /var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat
and check the ownership of the file
ls -l /var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat
. But actually, it is more likely you made a typo in the filename
I got this error log:
move_uploaded_file() enter code here [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpGmUpFW' to 'images/test#yahsoo.com.jpg' in enter code here[..]send.php on line 32
also error log
`include(user_agent.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/[irelevent]/Craciun2013/index.php on line 63`
line32 states:
if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file)) {
Please help.
It seems php (either www-data, apache or whatever user runs it) doesn't have permission on your current path. Have you checked who's the folder owner and what permissions does it have?
$response = file_get_contents($requestUri,0, $context);
gives the following errors
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\wamp\www\bing_basic.php on line 58
Warning: file_get_contents(https://api.datamarket.azure.com/Bing/Search/Web?$format=json&Query=%27dfg%27): failed to open stream: No such file or directory in C:\wamp\www\bing_basic.php on line 58
Any advice on how to go about removing them?? I am using a Bing API key to get results on a HTML page using WAMP.
Enable extension=php_openssl.dll within your php.ini file, then restart your server.
Using PHP Version 5.3.15 with Apache 2 on a Mac Web Server.
A while back (it's been years) I had this working right and I have no idea what has changed so I was wondering if anyone has a solution.
What I would like to happen is when a file with a "0" permission in the everyone slot (ie 770, 640, etc) is called by the browser from our server the user gets a 404 or page not found. Right now if a file with 0 for everyone is opened the following is displayed in the browser:
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/path to site/www/membership/donate_vehicle.php' (include_path='.:') in Unknown on line 0
Example: http://wfsu.org/membership/donate_vehicle.php
Does anyone know how to make a 404 page there instead? It's got to be a configuration or something, because like I said, it was this way on our old server, which was an older Mac server running an older version of PHP and Apache, just not sure what.
Thanks
$myfile = '/path/to/file.php';
if( file_exists($myfile) && is_readable($myfile) ) {
require($myfile);
} else {
// do 404 stuff
}