473,657 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1774
ph********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.com> ...
ph********@hotm ail.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********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.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********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.com> ...
ph********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.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********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.com> ...
ph********@hotm ail.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***@jerrysie vers.com> wrote in message news:<m3******* *****@prod01.je rrysievers.com> ...

Jul 17 '05 #9

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

Similar topics

6
4555
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 restarts and all active sessions are terminated. This error is also described in detail here:...
62
17744
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(); img.src = ; Then I use the image a few more times by adding it into an Array object:
4
2002
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 table, I have the separate images stored in an image directory with primary key as the filename (3476.jpg). If the image exists, I display the image. All this works fine. I have a buttons that allow for the insertion and deletion of photos. ...
3
2869
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, removing all the files/folders inside it. The problem i am having is that i can only delete files in the Windows/Temp folder, and i can't delete folders if they contain files, i know that you can't do this.
6
2129
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 a database named TANI and it has a table named "TANI" as well. Table TANI has 3 fields only ------ 1. CSV FILES that holds a link to some csv files from a folder 2. IMAGE FILES that holds a link to some image files from...
6
15070
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 is being used by other process. Is there a way to "free" the file? Thank you for your help.
4
1747
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. I do this by using the image.fromfile function: pbProduct.Image = Image.FromFile(myImagePath & productkey & ".jpg") Now I'm building the option to delete a product. When a product is selected
0
1371
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. When I press record the video is recorded and when I press send, a filename is created for it along with a thumbnail image, and the date and duration of the video which is stored in a datacontainer on the right of the main interface. When I select...
5
23875
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 delete the loaded image file from the directory. But I have a problem deleting the image file used by the picturebox even if I set the "PictureBox1.Image = Nothing" before deletion takes place. The error says, "The process cannot access the file...
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.