473,756 Members | 3,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

move_uploaded_f ile, fileowner, chown etc.

I have a form handler script that creates a new folder for the files sent in
the form. Move_uploaded_f ile transfers then puts those files there.

But problem is that apache becomes automaticly owner of folder and files, so
later I cannot delete/rename/transfer those files trough winscp. Only load
them if permissions are set ok.

Chown doesn't work, because only superuser can change file's owner. What can
I do? Make 24 h agreement with superuser? Become superuser? Now i fell more
like superloser. I create files but i cannot delete them.

--
Perttu Pulkkinen
www.risteys.net
www.onnenliinat.com
www.palvelukaupunki.fi
Jul 17 '05 #1
4 2587
*** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):
Chown doesn't work, because only superuser can change file's owner. What can
I do?


Try changing the group with chgrp() and giving rights to the group. In many
Linux distros user's main group is a group named after the username that is
created automatically. That's it, user john belongs to group john.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #2
"Alvaro G Vicario" wrote:
*** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):
Chown doesn't work, because only superuser can change file's owner.
Try changing the group with chgrp() and giving rights to the group. In many Linux distros user's main group is a group named after the username that is created automatically. That's it, user john belongs to group john.


Chgrp doesn't work either, because only superuser can change file's group.
Jul 17 '05 #3
Perttu Pulkkinen wrote:
"Alvaro G Vicario" wrote:
*** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):
> Chown doesn't work, because only superuser can change file's owner.

Try changing the group with chgrp() and giving rights to the group. In

many
Linux distros user's main group is a group named after the username that

is
created automatically. That's it, user john belongs to group john.


Chgrp doesn't work either, because only superuser can change file's group.


It does work. The apache user must be in the group.

So if user John is in group "John", and you want John to be able to
manipulate files uploaded by apache, then put apache into that group also.
Then apache will be able to chgrp its own files to group John.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec )ure(Dat)a(.com )
Jul 17 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Try using FTP

Something like...

$id_con = ftp_connect("lo calhost");
$resultado_logi n =
ftp_login($id_c on, "ftp_user", "ftp_pass") ;
if ((!$id_con) || (!$resultado_lo gin)) return 0;

if(!file_exists ("my_folder" ))
ftp_mkdir($id_c on,"/_other_/_ftp_folders/my_folder");
$carga = ftp_put($id_con ,
/_other_/_ftp_folders/my_folder/myfile,
$_FILES["myfile"]['tmp_name'], FTP_BINARY);
if(!$carga) return 0;
else return 1;
ftp_close($id_c on);

This is what I do to avoid the problem ^^

Greets.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)

iD8DBQFCn1YDlrI 0xkZFpzMRAlA3AK CuNDZdmOnAuEOIx 4K33hWvEmJDhACf dUje
wgPpTlbeLoyMD8I WVHlmRo4=
=TrhR
-----END PGP SIGNATURE-----
Jul 17 '05 #5

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

Similar topics

5
7647
by: neo002244 | last post by:
The move_uploaded_file() function is very quirky. I want to allow users to upload images to the Web site. Here is the code: if(!move_uploaded_file($_FILES, $imagefile)) { die("Could not move file: ".$_FILES." -> $imagefile"); } else { enter record into database...
2
5745
by: Sean | last post by:
What is meant by: "CHOWN the entire casetracker folder to something that permits the server to write to it, such as apache.apache, or whatever your Webmaster recommends" - is that 700 or 777...Help Sean
1
3017
by: Felix Natter | last post by:
hi, I would like to upload a file (via a form), then read that (temporary) file and write the contents into a database. The first problem is that open_basedir=/home/CUSTOMER so I can't just read it from /tmp. That's why I used move_uploaded_file() to move the file to /home/CUSTOMER/DOMAIN/tmp/FILENAME: ======================================================
1
10682
by: sa | last post by:
Trying to upload a file using win xp/iis/php. I've given full access to all accounts trying to get this to work? Yet I'm still getting read errors. Simplified the script below to the bare minimum. simpleupload.php <form enctype="multipart/form-data" action="upload.php" method="post"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="200000"/>
6
3374
by: Stijn Goris | last post by:
HI all, I have created a script that allows a user to upload a picture. I have an IIS server runing on my own pc but the actual site runs an Apache server. The upload script worked perfectly on my IIS but refuses to work on the Apache. All I know is that the script stops working at move_uploaded_file() function. The warnings echo'ed are: Warning: move_uploaded_file(images/nieuws/TIDEEY%7E1.jpg): failed to open
2
16298
by: Brian | last post by:
Hi I am moving a site to a new server, I have been testing it and one of the pages uses move_uploaded_file, but I get a Permission denied. The directory I am moving it to is chomd of 755, if I change it to 777 it does upload but the owner is www-data, but I then can't download it using a FTP client (which I have to do) as it's the wrong owner, so I have to leave the chomd as 755, but
3
10064
by: James Colannino | last post by:
Hey everyone. I tried to use os.chown() in the following manner: os.chown('filename', 'username', 'groupname') I got an error, and when I googled for this function I realized that I must pass the numerical uid and gid. My question is, is there a way for me to change ownership based on the name instead of the number? Perhaps there's a function that will let me lookup the uid from the username, and the gid from the groupname?
5
3373
by: bill | last post by:
I can validate that the file uploaded because is_uploaded_file() returns true. --------- if (is_uploaded_file($_FILES)) { echo "File ". $_FILES ." uploaded successfully.<br />"; } ------------------------ When I try to move the file using move_uploaded_file it fails. --------------
2
2428
by: Taorluath | last post by:
I just made a simple program to create files; I'm trying to get the hang of basic file manipulations. Whatever file my program makes, the owner of the file is "www-data," so I can't edit it using my regular server user. I can use root to change the ownership to the server user, but I don't want to do that for every file. That's why I tried to use chown() to give ownership to the server as soon as the file is made, but I get this error: ...
0
9462
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
9287
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
10046
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
9886
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
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...
1
7259
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
6542
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
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.