Solved

Changing permissions of uploaded file

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

726 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