473,406 Members | 2,336 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.

Deleting Image Files from CMS

Hi there,

I have built a CMS, and in one part you have to be able to
delete images. Structure like this:

_root --> folder "img" --> file "1.jpg"
--> file "2.jpg"

--> folder "CMS" --> file "edit_text.php"
--> file "delete_img.php" (function 'unlink()' in it)

When i run "delete_img.php" it only works when i manually CHmod everything
0777 with an FTP-program.

Of course, that's not what i want when i have a CMS, and i don't want to leave
the "img"-folder CHmodded 0777, but after deleting the image i want it 0755
again...
And now the problem: chmod("../img/", 0777); doesn't work :(
I get the following error:

"Warning: chmod(): Operation not permitted in PATH"

Is there an alternative for unlink, or a way to get the CHmod to work..?

Thanks to all!
Jul 17 '05 #1
8 1764
ph********@hotmail.com (phpfrizzle) writes:
I have built a CMS, and in one part you have to be able to
delete images. Structure like this:

When i run "delete_img.php" it only works when i manually CHmod everything
0777 with an FTP-program.

And now the problem: chmod("../img/", 0777); doesn't work :(
I get the following error:

"Warning: chmod(): Operation not permitted in PATH"


This error happens because the UID of the webserver process is not
owner of those files/dirs or root.

Well, who created those files and directories in the first place?
File perms and in general, ownership not relevant on deletion (unlink)
in Unix. This is Unix isn't it? It';s the directory permission bits
that matter since unlinking a file means makeing changes to a
directory.

Assuming your PHP code is being run by mod_php, the directories that
the images reside in must be writeable to the UID the webserver
process runs as.

Study up on owner and group access privs and go from there.

Quick solution probably to make the image dirs group writeable to
Apache. 0775 means read, write, search to owner read write, search to
group and read, search to world.

Figure out your GID of webserver by either looking in httpd.conf,
seeing it in a PS listing, seeing it in /etc/passwd etc.

HTH
--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 17 '05 #2
Hi there,

Me again, i took Jerry's advice, and tried the USER settings etc., but
i still have the same problem. Even when i checked all nine the checkboxes
and other combinations....

Or am i searching in the wrong place?
I have Plesk 7. When i admin my files, there are a few variables for each
file/dir:

... Owner Group Permissions ...
name psacln rwx r-x r-x
But as i told you, permissions didn't work :(
I noticed i have the same problem with moving uploaded files....

Any help would be greatly appreaciated

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...
ph********@hotmail.com (phpfrizzle) writes:
I have built a CMS, and in one part you have to be able to
delete images. Structure like this:

When i run "delete_img.php" it only works when i manually CHmod everything
0777 with an FTP-program.

And now the problem: chmod("../img/", 0777); doesn't work :(
I get the following error:

"Warning: chmod(): Operation not permitted in PATH"


This error happens because the UID of the webserver process is not
owner of those files/dirs or root.

Well, who created those files and directories in the first place?
File perms and in general, ownership not relevant on deletion (unlink)
in Unix. This is Unix isn't it? It';s the directory permission bits
that matter since unlinking a file means makeing changes to a
directory.

Assuming your PHP code is being run by mod_php, the directories that
the images reside in must be writeable to the UID the webserver
process runs as.

Study up on owner and group access privs and go from there.

Quick solution probably to make the image dirs group writeable to
Apache. 0775 means read, write, search to owner read write, search to
group and read, search to world.

Figure out your GID of webserver by either looking in httpd.conf,
seeing it in a PS listing, seeing it in /etc/passwd etc.

HTH

Jul 17 '05 #3
ph********@hotmail.com (phpfrizzle) writes:
Hi there,

Me again, i took Jerry's advice, and tried the USER settings etc., but
i still have the same problem. Even when i checked all nine the checkboxes
and other combinations....

Or am i searching in the wrong place?
I have Plesk 7. When i admin my files, there are a few variables for each
file/dir:

... Owner Group Permissions ...
name psacln rwx r-x r-x


What is this a file or dir? If it's a dir and isn't owned by the UID
that webserver runs as, the webserver isn't going to be able to delete
files from there.

--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 17 '05 #4
Hi there again, thanks for taking the effort to read this.

It was a dir. I managed to get the upload script to work 'right'.
The file is uploaded, renamed & moved. And the file even gets CHmodded! :D
Executing script and it's folder are both set 'rwx rwx r-x'.

BUT... :-(
It only seems to work when i set the images dir-permissions to
'rwx rwx rwx' (0777) instead of 'rwx rwx r-x' (0755). So that's my first
question: is this dangereous, should it be different?

And my second:
The file uploaded has uid & gid 'apache' instead of the uid/gid
i'm running the upload script from. I tried the following:
chown ( "../img/$id.jpg", "uid"); // correct uid
chgrp ( "../img/$id.jpg", "gid"); // correct gid

But that just gives me errors. :(
Warning: chown(): Operation not permitted
Warning: chgrp(): Operation not permitted

CHmod works though....
So how do i change them to the right settings?

I am new to this uid/gid stuff, so please be gentle... ;)

Greetings

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...

What is this a file or dir? If it's a dir and isn't owned by the UID
that webserver runs as, the webserver isn't going to be able to delete
files from there.

Jul 17 '05 #5
ph********@hotmail.com (phpfrizzle) writes:
Hi there again, thanks for taking the effort to read this.

It was a dir. I managed to get the upload script to work 'right'.
The file is uploaded, renamed & moved. And the file even gets CHmodded! :D
Executing script and it's folder are both set 'rwx rwx r-x'.

BUT... :-(
It only seems to work when i set the images dir-permissions to
'rwx rwx rwx' (0777) instead of 'rwx rwx r-x' (0755). So that's my first
question: is this dangereous, should it be different?
Yes and yes. But unless you are root, you can't change
owner/groupership of the upload images dir correctly and you'll have
to make do with world write perms.

And my second:
The file uploaded has uid & gid 'apache' instead of the uid/gid
i'm running the upload script from. I tried the following:
chown ( "../img/$id.jpg", "uid"); // correct uid
chgrp ( "../img/$id.jpg", "gid"); // correct gid
I think you are confused about who's who when these things are
running.

But that just gives me errors. :(
Warning: chown(): Operation not permitted
Warning: chgrp(): Operation not permitted
Of course. Non root users can't change file ownerships. This used to
be possible on some versions of Unix but generally isn't any more.

CHmod works though....
So how do i change them to the right settings?
You can't As a regular user. You need to get someone with root privs
on this box involved to change dir ownerships and modes as needed.

This is about all the help I can give you.

I am new to this uid/gid stuff, so please be gentle... ;)

Greetings

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...

What is this a file or dir? If it's a dir and isn't owned by the UID
that webserver runs as, the webserver isn't going to be able to delete
files from there.


--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 17 '05 #6
Well, thank you again Jerry for taking the effort.
I understand what you mean...

What i don't get, is that i am the 'owner' of the site, and i have
an admin panel etc. to create users etc. Is it in there, or could it be
useful to contact the host about this?

Thanks again Jerry!

Greetings phpfrizzle

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...
ph********@hotmail.com (phpfrizzle) writes:
Hi there again, thanks for taking the effort to read this.

It was a dir. I managed to get the upload script to work 'right'.
The file is uploaded, renamed & moved. And the file even gets CHmodded! :D
Executing script and it's folder are both set 'rwx rwx r-x'.

BUT... :-(
It only seems to work when i set the images dir-permissions to
'rwx rwx rwx' (0777) instead of 'rwx rwx r-x' (0755). So that's my first
question: is this dangereous, should it be different?


Yes and yes. But unless you are root, you can't change
owner/groupership of the upload images dir correctly and you'll have
to make do with world write perms.

And my second:
The file uploaded has uid & gid 'apache' instead of the uid/gid
i'm running the upload script from. I tried the following:
chown ( "../img/$id.jpg", "uid"); // correct uid
chgrp ( "../img/$id.jpg", "gid"); // correct gid


I think you are confused about who's who when these things are
running.

But that just gives me errors. :(
Warning: chown(): Operation not permitted
Warning: chgrp(): Operation not permitted


Of course. Non root users can't change file ownerships. This used to
be possible on some versions of Unix but generally isn't any more.

CHmod works though....
So how do i change them to the right settings?


You can't As a regular user. You need to get someone with root privs
on this box involved to change dir ownerships and modes as needed.

This is about all the help I can give you.

I am new to this uid/gid stuff, so please be gentle... ;)

Greetings

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...

What is this a file or dir? If it's a dir and isn't owned by the UID
that webserver runs as, the webserver isn't going to be able to delete
files from there.

Jul 17 '05 #7
ph********@hotmail.com (phpfrizzle) writes:
Well, thank you again Jerry for taking the effort.
I understand what you mean...

What i don't get, is that i am the 'owner' of the site, and i have
an admin panel etc. to create users etc. Is it in there, or could it be
useful to contact the host about this?
I think you should contact them. Those admin panels can only do so
much. The rest needs to be done as root, by manual login (telnet, ssh
etc.) most likely.

Thanks again Jerry!

Greetings phpfrizzle

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...


--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 17 '05 #8
Ok Jerry, thanks a lot, i'll contact them.
Thanks for helping with all this.

The original problem is still solved... :D

Greetings and thanks again!

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...
ph********@hotmail.com (phpfrizzle) writes:
Well, thank you again Jerry for taking the effort.
I understand what you mean...

What i don't get, is that i am the 'owner' of the site, and i have
an admin panel etc. to create users etc. Is it in there, or could it be
useful to contact the host about this?


I think you should contact them. Those admin panels can only do so
much. The rest needs to be done as root, by manual login (telnet, ssh
etc.) most likely.

Thanks again Jerry!

Greetings phpfrizzle

Jerry Sievers <je***@jerrysievers.com> wrote in message news:<m3************@prod01.jerrysievers.com>...

Jul 17 '05 #9

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

Similar topics

6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
4
by: TomA | last post by:
Hi All, I have a picturebox on a form containing the photo of a person. As you advance through the records, the photo updates. Rather than storing the images in an inefficient blob field in a...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
6
Zerin
by: Zerin | last post by:
Hi guys, I started "autopurging" discussion many days ago.As I couldn't do it,so I decided to change my database into SQL Server.And so posted this problem here. Plain and simple ------ I have...
6
by: FrankB | last post by:
Hello, after setting another image to the picture box it is not possible to delete the last shown file via File.Delete ( sFilename). Path of image file is correct. Error message box says: file...
4
by: Bart Steur | last post by:
Hi, I'm writing an app to maintain products. The products are listed in a listbox and when I click a product in a listbox some info of that product is shown including a picture of the product. ...
0
by: hott5hotj | last post by:
Hi guys, I've been working on a project to record video and audio using a standard webcam and microphone. I have been given the basic coding and have it running using wowza media server and apache....
5
krungkrung
by: krungkrung | last post by:
hi again to everyone! I made a simple program(for my VB.Net practice). The program loads an image file to a picturebox upon clicking a button. after loading the image file i have another button to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.