PHP: move_uploaded_file(): Unable to move '/ - php

I keep getting this error on a new server I just setup
[Wed Feb 16 22:46:51 2011] [error] [client 71.1.236.114] PHP Warning:
move_uploaded_file(upload/110216104651_00134_smooth_1440x900.jpg):
failed to open stream: Permission denied in /var/www/admin/_application/models/Roles.model on line 1757,
referer: http://nacc.biz/admin/admin/modifyarticle.php?roleid=4
[Wed Feb 16 22:46:51 2011] [error] [client 71.1.236.114] PHP Warning: move_uploaded_file():
Unable to move '/tmp/php6wlOg1' to 'upload/110216104651_00134_smooth_1440x900.jpg'
in /var/www/admin/_application/models/Roles.model on line 1757, referer:
http://nacc.biz/admin/admin/modifyarticle.php?roleid=4
[Wed Feb 16 22:46:51 2011] [error] [client 71.1.236.114] PHP Notice:
Upload Error: Error moving from temp dir in /var/www/admin/_application/models/Roles.model on line 1759,
referer: http://nacc.biz/admin/admin/modifyarticle.php?roleid=4
I added 777 and created a uploads dir, but the error persists. How do I find the path that needs to either be corrected or created?

Change owner of upload/ to www-data:www-data and also chmod to 755

Looks like it doesn't know where upload/ is. Make sure you have the full path in your statement. For example, if upload directory is actually located in /var/upload, then make sure that is in your statement, not just upload/.

Log into your ftp and confirm the following:
The folder exists, check for spellings
Check the properties of the folder and make sure the permissions have read+write 0666
Make sure the file is within your public html root, otherwise double check the owner of the file, and make sure PHP Has read / write access to it.
looking at the log:
Unable to move '/tmp/php6wlOg1' to 'upload/110216104651_00134_smooth_1440x900.jpg'
It seems to me that its looking in your root directory as upload/110216.... should be path.to/public_html/upload/110216....
If none of the above work, please post your line of code that has move_uploaded_file on.

It's trying to move the file to upload/ not uploads/, make sure the directory exists and is writable.

Provided, there are no spelling mismatches, give your upload directory (that directory ONLY) all user rights sudo chmod a+rwx /path/to/folder, that should fix the problem easily.
For a quick further read about permissions in Ubuntu, check here.

Related

Why doesn't my tmp_file_upload file exist? I'm using php 5.6

I'm trying to get website to upload images and I'm getting this error:
[Fri Oct 23 21:42:30.075831 2015] [:error] [pid 18652] [client ::1:64412] PHP Warning:move_uploaded_file(): Unable to move '/private/var/tmp/php0HlxVu' to 'images/photo.jpg' in /Users/ridgefrancis/Sites/examples/ch05/initial/guitarwars/addscore.php on line 32, referer: http://localhost/~ridgefrancis/examples/ch05/initial/guitarwars/addscore.php
I've seen the solution to this question already here:
move_uploaded_file gives "failed to open stream: Permission denied " error after all configurations i did
In my attempt to follow these instructions to fix the problem I ran into another problem,
tmp_file_upload file/folder doesn't exist.
What do I do in a case like this?
Thanks in advance!
I was thinking that my upload was not working because of my tmp_file_upload folder but it wasn't. I searched the internet and found out that ppl suggested it was because of that folder.
This piece of code solved my problem.
sudo chmod -R a+w /PATH/TO/IMAGE/FOLDER
I hope it helps someone in the future with the same issue.

PHP unable to open include file

I have a problem with a PHP script. The following error is being logged whenever the site is accessed:
[Fri Sep 26 11:57:56 2014] [error] [client 31.22.44.2]
PHP Fatal error: require_once(): Failed opening required
'./sites/default/modules/views/handlers/views_handler_field_markup.inc'
(include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc
on line 76
I have confirmed that the file referenced is present, and that www-data can access it. Permissions look fine and have not been changed as far as I am aware
What am I missing?
[Fri Sep 26 11:57:56 2014] [error] [client 31.22.44.2] PHP Fatal
error: require_once(): Failed opening required
'./sites/default/modules/views/handlers/views_handler_field_markup.inc'
(include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc
on line 76
Add path /var/www/www.xoomtalk.com/htdocs into your include_path
More explains:
your include_path=.:/usr/share/php:/usr/share/pear , means php script will find include file in: current_path, /usr/share/php or /usr/share/pear
when you want to require this file
./sites/default/modules/views/handlers/views_handler_field_markup.inc
all allowed path are:
(current path)
/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/./sites/default/modules/views/handlers/views_handler_field_markup.inc
(/usr/share/php) /usr/share/php/./sites/default/modules/views/handlers/views_handler_field_markup.inc
(/usr/share/pear)
/usr/share/pear/sites/default/modules/views/handlers/views_handler_field_markup.inc
In these path ,php can't find the file.
in the following file:
/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc
on line 76
Change This:
'./sites/default/modules/views/handlers/views_handler_field_markup.inc'
to THIS: '/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/handlers/views_handler_field_markup.inc'
This should do the trick.
The problem is, you're using scripts from various directories, but the "root" of the request is the cwd (current working directory) which you can check with: getcwd()
(and you're requesting the include relative to the cwd.
I managed to solve this problem, ended up being nothing to do with permissions or paths, although there was no indication of this in the Apache logs.
The problem was that the server was also running AppArmor which for some reason was blocking the Apache process from accessing the files.
AppArmor was set to complain rather than enforce mode for testing (command is aa-complain apache2) this made everything start working.
Thanks to all contributors for their suggestions.

Why I'm getting the PHP Fatal error in following scenario?

I'm using LAMP on my local machine. I'm getting the following error in apache error log and a blank web page in browser when I hit the URL:http://localhost/smart-rebate-web/web/admin/forgot_password.php
Following is the error I got in apache error log:
[Tue Apr 15 17:10:18 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required 'includes/public-application-header.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/smart-rebate-web/web/admin/forgot_password.php on line 2, referer: http://localhost/smart-rebate-web/web/admin/login.php?lout=1
For your reference I'm attaching the image of my project structure titled 'smart-rebate-web' in Netbeans editor.
and following is the sceenshot of abrwser after I hit the URL :
http://localhost/smart-rebate-web/web/admin/forgot_password.php
So can anyone please help me in resolving this issue please? Thanks in advance. If you want any further information or any code I can provide you the same. Following asre the permissons of these files if I print in terminal:
-rw-rw-r-- 1 eywa eywa 1646 Apr 14 13:05 application-header.php
-rw------- 1 eywa eywa 1006 Apr 10 18:06 public-application-header.php
You have permission issue. According to your current file permission, only file owner can read and write that file, others cannot read. When you go on browser, default www-data user tries to read that file. And it is not permitted. Make your file 644 or change file owner to www-data. ``www-data` is the apache user used while you open php files from browser. And more flexible way, use following;
require_once(dirname(__FILE__) . "/includes/public-application-header.php");
Try using
require_once('web/admin/includes/<filename>');

Permission denied on codeigniter

I'm running an Apache server on my PC with Debian 7 (well, actually Crunchbang, but it's the same thing).
I was playing with the CodeIgniter framework, and it was working all right. I completed the first tutorial, the one in which you create your first static page (this one: http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html ), and it worked perfectly.
However, as you can see on the very first step, there's a line that goes like this:
[...]
public function view($page = 'home')
[...]
I changed that line to " $page = 'about' ", to try if it could display the other page instead. That's when Hell opened its doors and released the Kraken.
Then it started to show a 404 error, so I changed the settings back again, but the error kept ocurring. I restarted Apache, restarted my PC (I don't know, sometimes it works) and finally, deleted the codeigniter files from my /var/www/ directory, and copied them again.
Now the error is different: It just displays nothing! A blank page, just that. This is what my apache errorlog says:
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/var/www/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/index.php on line 202
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/var/www/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 202
It sounds like the permissions are set incorrectly on your server.
Check what group Apache runs in (I think Debian by default uses www-data), and make sure you set the group owner and read permissions.
# chown www-data:www-data -R /var/www
# chmod g+r -R /var/www
If the above doesn't work, try setting permissions to 777 just to see if the problem lies elsewhere. I couldn't imagine what else could cause that error, though.

Are there any hidden php right permission using imagejpeg() or in apache & php in general? Getting Unable to open Permission denied

I am getting Unable to open ... for writing: Permission denied when I try and resize an image. The code has worked fine for years but after a resent upgrade (I think ) It has stopped working. I have tried changing the permission on the folder to 777 and disabled selunix. Is there any thing that may have changed in my httpd.con file or php.ini file that will disabled a php script right?
The error message from Apache logs:
[Mon Jun 25 08:59:17 2012] [error] [client 127.0.0.1] PHP Warning: imagejpeg(): Unable to open './cache/150_112.5_be636f82ef8e7e22727c81980df16cd5.jpg' for writing: Permission denied in /var/www/html/resize_function.php on line 62, referer: http://jasonrmoore.info/list.php?dir=./
Nop, this is an unix permission issue.
Please check the permission of the permissions of ./cache folder and inner files.

Categories