Try to upload an image using php - php

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?

Related

"move_uploaded_file (/var/www/html/crm/upload/36379.jpg): failed to open stream: Permission denied"

When a user uploads a file and I want to move it from temp directory to upload directory, I got this error message in the browser:
Warning: move_uploaded_file(/var/www/html/crm/upload/36379.jpg): failed to open stream: Permission denied in /var/www/html/crm/register_free_adviser.php on line 373
Warning: move_uploaded_file(): Unable to move '/tmp/phpeXf3DM' to '/var/www/html/crm/upload/36379.jpg' in /var/www/html/crm/register_free_adviser.php on line 373
bool(false)
OS: centOS 7
the project works fine on my system which runs windows,XAMPP,apache. but on my server which runs centOS I have issues.
I tried this solution but the problem didn't get solved.

Error messages for uploading files

I keep getting these error messages when using a plug in "üsers ultra pro":
Warning: mkdir(): No such file or directory in /homepages/2/d644181673/htdocs/app646332697/wp-content/plugins/users-ultra-pro/xooclasses/xoo.userultra.customizer.php on line 227
Warning: move_uploaded_file(/homepages/2/d644181673/htdocs/app646332697/usersultramedia/custom_avatar_image/uultra_default_avatar_image_.jpg): failed to open stream: No such file or directory in /homepages/2/d644181673/htdocs/app646332697/wp-content/plugins/users-ultra-pro/xooclasses/xoo.userultra.customizer.php on line 230
Warning: move_uploaded_file(): Unable to move '/tmp/phpTloN3B' to '/homepages/2/d644181673/htdocs/app646332697/usersultramedia/custom_avatar_image/uultra_default_avatar_image_.jpg' in /homepages/2/d644181673/htdocs/app646332697/wp-content/plugins/users-ultra-pro/xooclasses/xoo.userultra.customizer.php on line 230
Warning: getimagesize(/homepages/2/d644181673/htdocs/app646332697/usersultramedia/custom_avatar_image/uultra_default_avatar_image_.jpg): failed to open stream: No such file or directory in /homepages/2/d644181673/htdocs/app646332697/wp-content/plugins/users-ultra-pro/xooclasses/xoo.userultra.customizer.php on line 234
I have checked all the permissions are set to 755 but it still won't work. Any ideas? Thanks :)
Background: I am running a multi user site on Wordpress (think pinterest) where users will be able to upload images/text.

file-get-contents : failed to open stream: No such file or directory in php

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

PHP Codeigniter error failed to open stream: Permission denied

I have been working on a project that uses codeigninter. I worked on it in Windows 7 and it was fine but after I moved this project on Ubuntu to work on it there, It gives me this error in every page/controller/method that I try to access:
Warning: require_once(/opt/lampp/htdocs/TS_Project/system/core/CodeIgniter.php): failed to open stream: Permission denied in /opt/lampp/htdocs/TS_Project/index.php on line 202
Fatal error: require_once(): Failed opening required '/opt/lampp/htdocs/TS_Project/system/core/CodeIgniter.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/TS_Project/index.php on line 202
The CodeIgniter.php file does exist, the path to it is correct and I am able to read and write in it ( I can open it in a text editor and modify it freely). I tried changing the file permission to it using the chmod command but nothing happens. Why is permission denied to the CodeIgniter.php file?
You need to change the permission of your TS_Project folder to 755.
You can do that by:
sudo chmod -R 755 /opt/lampp/htdocs/TS_Project

404 needed instead of Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 on pages with XX0 permissions

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
}

Categories