Solved

Changing permissions of uploaded file

Posted on 2006-07-12
2
205 Views
Last Modified: 2008-02-26
Hello.

I use the following to upload a file.  The problem is that after it has been uploaded I CANNOT delete it from my FTP.  I think the permissions are off.

Any ideas?  Thanks!

<?php
$ftmp = $_FILES['image']['tmp_name'];
$oname = $_FILES['image']['name'];
$imagedir=$_REQUEST['imagedir'];
$fname = 'upload/'.$imagedir.'/'.$_FILES['image']['name'];
if(move_uploaded_file($ftmp, $fname)){
chmod($fname,0777);?>
0
Comment
Question by:hankknight
2 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 500 total points
ID: 17112799

the problem is that file creation/deletion make up to the parent directory's permissions.

upload/imagedir/file.jpg

i supposed you proceded this way:
"upload" is owned by FTPUSER, and you chmod'ed it 777 to allow WEBUSER operate in it.

you called php's mkdir() function to create "upload/imagedir". now the inner directory is owned by WEBUSER and is probably 755 permission. this won't allow FTPUSER to delete/create files inside it.

solution #1: chmod 777 "upload/imagedir", you need to do this from WEBUSER (i.e. php script)

solution #2: purge the whole directory structure (from WEBUSER), and create it from FTPUSER with chmod 777.
0
 
LVL 16

Author Comment

by:hankknight
ID: 17137171
Thank you!  By the way, I have posted a related question here:

http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_21924266.html
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question