[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Changing permissions of uploaded file

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
hankknight
Asked:
hankknight
1 Solution
 
ThGCommented:

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
 
hankknightAuthor Commented:
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now