473,769 Members | 6,597 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 2590
*** 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
7648
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
5746
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
10683
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
3376
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
16300
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
10065
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
2430
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
9589
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
9423
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
10214
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
10048
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
9996
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
9865
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
8872
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...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2815
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.