Solved

Changing permissions of uploaded file

Posted on 2006-07-12
2
202 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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now