473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

move_upoaded_file permissions problem - Does something need configured on server?

Hi,

I am trying to carry out an upload and save file in directory operation
using move_uploaded_file(). However, when I run the script it give me
the following error:

Warning: move_uploaded_file(photos/sonyericsson_t610.jpg): failed to
open stream: Permission denied in
/home/martyn69/public_html/photos/add_photo.php on line 41

Warning: move_uploaded_file(): Unable to move '/tmp/phphPIdIj' to
'photos/sonyericsson_t610.jpg' in
/home/martyn69/public_html/photos/add_photo.php on line 41
I have ensured that the permissions for the folder are set to 777.
Also, I know that the file has been successfully uploaded as I have got
the processing script to display the filename, size, type etc. The
problem occurs at the move_uploaded_file() part. Does something need
configured on the server for this to work?

Cheers

Martyn Bissett

Jul 31 '06 #1
3 1722
bizt wrote:
Hi,

I am trying to carry out an upload and save file in directory operation
using move_uploaded_file(). However, when I run the script it give me
the following error:

Warning: move_uploaded_file(photos/sonyericsson_t610.jpg): failed to
open stream: Permission denied in
/home/martyn69/public_html/photos/add_photo.php on line 41

Warning: move_uploaded_file(): Unable to move '/tmp/phphPIdIj' to
'photos/sonyericsson_t610.jpg' in
/home/martyn69/public_html/photos/add_photo.php on line 41
I have ensured that the permissions for the folder are set to 777.
Also, I know that the file has been successfully uploaded as I have got
the processing script to display the filename, size, type etc. The
problem occurs at the move_uploaded_file() part. Does something need
configured on the server for this to work?

Cheers

Martyn Bissett
Hi Martyn,

2 folders are of import in this situation:
1) The folder where PHP stores the temp-file containing the uploaded file.
Often this is the temp directory.
2) The folder where you want to move the file to.

Maybe you have an exotic situation where PHP can store the file in the
tempdir, but has NO readpermissions on it. (Write yes, read no).

To check if this is the case:
1) check which directory is used to by PHP to store tempfiles,
2) check its filepermissions for user PHP (apache/nobody/www-data, whatever
that is in your case).

Hope that helps.
Regards,
Erwin Moller
Jul 31 '06 #2
To check if this is the case:
1) check which directory is used to by PHP to store tempfiles,
2) check its filepermissions for user PHP (apache/nobody/www-data, whatever
that is in your case).
Thanks for that

Now, I purchase my webspace from a hosting company. Would I, in most
cases, have access to the temp dir and would I be able to change the
file permissions? I contacted my hosting company and they made some
changes that allowed it to work but they didnt give much info into what
was carried out.

Cheers

Burnsy

Jul 31 '06 #3
bizt wrote:
>To check if this is the case:
1) check which directory is used to by PHP to store tempfiles,
2) check its filepermissions for user PHP (apache/nobody/www-data,
whatever that is in your case).

Thanks for that

Now, I purchase my webspace from a hosting company. Would I, in most
cases, have access to the temp dir and would I be able to change the
file permissions?
Yes, under most setups you have both write and read permissions on such a
temp dir.
Of course, the filepermissions of the files you want to access (via
move_uploaded)file()) IN the tempdir is what really matters.

Maybe your hostingcompany made PHP store files as the PHP-user with no
readrights, which sounds very strange to me.

You can check this yourself by using php_info(), and see what you can find
out about the tempdirectory. If you have shellaccess you can see the
directorypermissions yourself.

I contacted my hosting company and they made some
changes that allowed it to work but they didnt give much info into what
was carried out.
Good it works now. Bad they didn't give you a short description on what they
changed. That way it is hard to learn what went wrong.
>
Cheers

Burnsy

Regards,
Erwin Moller
Jul 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BingoHandJob | last post by:
Hello group! I'm having a problem and I hope some of you may be able to point me in the right direction. I inherited a web site using php, running on Windows 2000 & IIS. The site was...
12
by: Angelos Karantzalis | last post by:
Is there a way to set Permissions based on user roles by using some configuration file for my application ? I'm coming from a Java background, where that could very easily be accomplished but...
1
by: MSDN Account | last post by:
We have web site that used the IIS ResKit tool MSWC.PermissionChecker to check file permissions. The web site has been upgraded and that upgrade included changing the default server side language...
11
by: Dave Schwimmer | last post by:
I am relatively new to PHP. One of the things that seems glaring obvious to me (coming from a C/C++ background) is how 'open' everything seems - (AFAIK). For instance, URLs typically have the name...
6
by: Fred W. | last post by:
When my application starts I need to check folder permissions to ensure they have "Full Control" before I let them proceed on. How can I check this permission. Thank you, Fred
5
by: Paul | last post by:
Hi just wondering if anyone has run into this, I get the error when I try to create a new web application using vs2003. thanks. -- Paul G Software engineer.
7
by: sprash | last post by:
Newbie question: I'm trying to determine if a file physically exists regardless of the permissions on it Using File.Exists() returns false if it physically exists but the process does not...
13
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
7
by: Bolwerk | last post by:
Hello I got a client who uses what appears to be ASP.NET 2.0. I come from a UNIX/PHP/Apache background, and I'm not too familiar with ASP.NET. He had some permissions problem a few weeks ago...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.