Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing permissions of uploaded file

Posted on 2006-07-12
2
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
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.
Suggested Courses

618 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