I have a php script which I use it for uploads. Before I switched to another server, but now it doesn't. This is the PHP file:
<?php
if($_FILES["file"]["error"] > 0){
echo "There was an error processing your upload. Please try again. ";
}else{
// Save this file in the directory
move_uploaded_file('$_FILES["file"]["tmp_name"]', '"uploads/".$_FILES["file"]["name"]');
}
?>
I'm not only getting this error in error.log:
[Sun Jul 21 12:32:34 2013] [error] [client 10.127.2.10] PHP Warning:
move_uploaded_file(uploads/file.
txt): failed to open stream: Permission denied in /home/liongold/Web/upload_script.php on line 6, referer
: http://url/upload_page.html
[Sun Jul 21 12:32:34 2013] [error] [client 10.127.2.10] PHP Warning: move_uploaded_file(): Unable to mov
e '/tmp/phpa0hsMc' to 'uploads/file.txt' in /home/liongold/Web/upload_script.php on line 6, referer: h
ttp://url/upload_page.html
This may because of permission problem. directory "uploads" must have write permission for upload to that directory.
Go to your control panel and set directory permission to 777.
I hope it will solve your problem.
Related
I am first time deploying my laravel project in a shared hosting.
I got error:
This page isn’t working. jsquarehospital.com is currently unable to handle this request.
HTTP ERROR 500
I deployed following this tutorial https://www.youtube.com/watch?v=6g8G3YQtQt4
Deploy Method: uploaded project zip in root directory, then uploaded the public folder in public_html and changes index.php
Please help me. My error log
[Sun Oct 18 14:00:33.054366 2020] [php7:warn] [pid 24621] [client 103.25.250.225:28241] PHP Warning: require(/home/jsquare/domains/jsquarehospital.com/public_html/../jshpanel/vendor/autoload.php): failed to open stream: No such file or directory in /home/jsquare/domains/jsquarehospital.com/public_html/index.php on line 24
[Sun Oct 18 14:00:33.054390 2020] [php7:error] [pid 24621] [client 103.25.250.225:28241] PHP Fatal error: require(): Failed opening required '/home/jsquare/domains/jsquarehospital.com/public_html/../jshpanel/vendor/autoload.php' (include_path='.:/usr/local/php73/lib/php') in /home/jsquare/domains/jsquarehospital.com/public_html/index.php on line 24
I am creating an Wordpress app server on apache and I am getting an error 500 while going to the url.So, I did check the httpd/logs/error_log and the following is the error
[Sun Jan 15 22:42:54.440349 2017] [:error] [pid 767] [client
10.203.116.148:9173] PHP Warning: require_once(/var/www/html/wp-config.php): failed to open stream:
Permission denied in /var/www/html/wp-load.php on line 37 [Sun Jan 15
22:42:54.440406 2017] [:error] [pid 767] [client 10.203.116.148:9173]
PHP Fatal error: require_once(): Failed opening required
'/var/www/html/wp-config.php'
(include_path='.:/usr/share/pear:/usr/share/php') in
/var/www/html/wp-load.php on line 37
I tried changing the file permissions for Wp-config.php but no luck, is there anything else I could do.
Try changing file permissions of wp-config.php it might be given 640. Change file permission of wp-config.php or .htaccess file to 644.
Changing file permission of wp-config.php to 644 worked for me
This error comes most of the time after migration, So the solution is to change the permission of wp-config.php to 644. You can easily change permissions from FileZilla
cheek the path on wp-load.php or post it here
.
I'm trying to control bitcoin daemon with PHP but I am having an issue when trying to connect to it.
I've followed these steps: en.bitcoin (dot) it/wiki/PHP_developer_intro
PHP code:
<?php
require_once 'jsonRPCClient.php';
$bitcoin = new jsonRPCClient('http://user:password#127.0.0.1:8332/');
echo "<pre>\n";
print_r($bitcoin->getinfo());
echo "</pre>";
?>
Bitcoind conf:
rpcuser=user
rpcpassword=password
server=1
daemon=1
listen=1
var/log/httpd/error_log:
[Tue Apr 06 15:47:15.403045 2015] [:error] [pid 2293] [client 10.0.0.34:50333] PHP Warning: fopen(http://...#127.0.0.1:8332/): failed to open stream: Permission denied in /var/www/html/jsonRPCClient.php on line 132 [Tue Apr 06 15:47:15.410993 2015] [:error] [pid 2293] [client 10.0.0.34:50333] PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://user:password#127.0.0.1:8332/' in /var/www/html/jsonRPCClient.php:140\nStack trace:\n#0 /var/www/html/bitcoin_get_info.php(15): jsonRPCClient->__call('getinfo', Array)\n#1 /var/www/html/bitcoin_get_info.php(15): jsonRPCClient->getinfo()\n#2 {main}\n thrown in /var/www/html/jsonRPCClient.php on line 1406
Edit:
$ bitcoin-cli getinfo
Works fine, with PHP it doesn't
Maybe try adding rpcallowip=127.0.0.1 into your config and see what happens.
Also make sure that your bitcoind.conf is actually being used, to test this you can set the daemon to testnet using testnet=1 in bitcoind.conf. Restart your bitcoind server then do bitcoin-cli getinfo to see which network it's connected to. If the change isn't reflected then perhaps the bitcoind.conf file is in another location?
Also, make sure you restart your bitcoind server every time you make a change to the bitcoind.conf file.
I'm trying to enable basic debug output with WordPress for a plugin I'm developing. I managed to get some so far, but failed to redirect it to wp-content/debug.log. I've been roughly following the guide by Douglas Neiner. Here's what I did:
I added this snippet of code to the end of wp-config.php:
#ini_set ('display_errors', 0);
define ('WP_DEBUG', true);
define ('WP_DEBUG_DISPLAY', false);
define ('WP_DEBUG_LOG', true);
I manually created debug.log file and made sure it's accessible by www-data user (I'm running WordPress locally, on Ubuntu 12.04):
septi#norbert:~$ sudo su www-data -c 'ls -l /usr/share/wordpress/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /usr/share/wordpress/wp-content/debug.log
septi#norbert:~$ sudo su www-data -c 'ls -l /srv/www/localhost/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /srv/www/localhost/wp-content/debug.log
septi#norbert:~$ sudo su www-data -c 'echo i can write >> /usr/share/wordpress/wp-content/debug.log'
septi#norbert:~$
Added a few supposed debug output statement inside the plugin activation hook, as well as the intentional error:
include ('i fail wp');
register_activation_hook (__FILE__, 'hello_world_activate');
function hello_world_activate()
{
error_log ('I love debug output when it works!');
}
What I expect is an error message about the missing include file in debug.log along with the "I love debug output when it works!" message, and nothing on the page. What I get is the missing include file on the page message and nothing in debug.log. The debug output message is not fully lost, however. I found it in the /var/log/apache2/error.log:
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] I love debug output when it works!, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
I suspect that the error_log() function is not the right one to use to output to debug.log, but I failed to find the right way. Oh, of course I could just hardcode the file path and append to it, but, you know...
I encountered the same problem with WordPress running in Apache 2.4 on Fedora 19. Output of error_log() was landing in /var/log/httpd/error_log instead of wp-content/debug.log. Httpd process had write permission (+775) to /var/www/html/wp-content directory, but it was unable to create the wp-content/debug.log file.
My wp-config.php debug setting was:
#ini_set(‘display_errors’,0);
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
As it turned out, the real cause was SELinux. I made SELinux policy change and allowed httpd to write to wp-content with following commands. (Refer SELinux Troubleshooter to get the actual command for your installation)
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/wp-content'
restorecon -v '/var/www/html/wp-content'
After this debug messages start appearing in wp-content/debug.log.
the error_log() function writes to the web server's error log (e.g. /var/log/httpd/error_log); what you want is trigger_error().
I have php upload problem, I have the following code:
define('GW_UPLOADPATH', '/var/www/train/ch5/images/');
$name = $_POST['name'];
$score = $_POST['score'];
$screenshot = $_FILES['screenshot']['name'];
$target = GW_UPLOADPATH.$screenshot;
echo $_FILES['screenshot']['tmp_name'].'<br/>';
move_uploaded_file($_FILES['screenshot']['tmp_name'], $targe)
or die("Upload Error!");
I get upload error! The temporary file where file is uploaded is:
/tmp/php9Khayp
but in /tmp I can not find this file. I am working on Ubuntu 10.10. Can anyone say me where is the problem?
apache error.log:[Wed Aug 10 20:54:17 2011] [error] [client ::1] PHP Warning: move_uploaded_file(/var/www/train/ch5/images/phizsscore.gif): failed to open stream: Permission denied in /var/www/train/ch5/addscore.php on line 22, referer: http://localhost/train/ch5/addscore.php
[Wed Aug 10 20:54:17 2011] [error] [client ::1] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpmkZEr3' to '/var/www/train/ch5/images/phizsscore.gif' in /var/www/train/ch5/addscore.php on line 22, referer: http://localhost/train/ch5/addscore.php
[Wed Aug 10 20:54:18 2011] [error] [client ::1] File does not exist: /var/www/favicon.ico
You have a typo. $targe should be $target.
move_uploaded_file($_FILES['screenshot']['tmp_name'], $targe)
---------------------------------------^^^^^^
Otherwise, you will never be able to see the file in /tmp because it only persists for the lifetime of the PHP script. As soon as the script execution completes, the file will be cleaned up. You can't ever access it on disk after the script terminates unless a successful call to move_uploaded_file() is made.
UPDATE
If the $target variable is not the problem, make sure that the Apache web server user (www-data, httpd, apache are possibilites) has write access to your target /var/www/train/ch5/images/:
# assuming the Apache user is apache...
sudo chown root:apache /var/www/train/ch5/images/
sudo chmod g+rwx /var/www/train/ch5/images/
Does your code have permission to write files to /tmp?
Do the apache error logs say anything?