Upload image with specific permissions

I have a form that uploads images on my site. The upload is done ok, i see the files with ftp. I insert the image in a html file but the browser can not display it. I checked the permissions of the image and they are set to (owner read+write, group nothing, others nothing).The folder i am uploading the image is 0777. I want to be able to upload the image with permissions read for everyone. Can this be done?
ypogeios0101Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (125)

Computer101
EE Admin
0
 
minichickenCommented:
Hmm... pretty strange, the files uploaded should by default at least have read access to everyone.
Read permission problem is really rare.... did you check the reference path of the image in your browser? Is the path pointing to the correct path and image?
0
 
ypogeios0101Author Commented:
if change the permision to read for everyone the image is displayed.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
minichickenCommented:
So is it working now? by setting a read permission for everyone? You question solved?
0
 
ypogeios0101Author Commented:
no. i manually changed the permissions. i am looking for a way to change the permission automatically when the file is uploaded.
0
 
minichickenCommented:
try this
// Read and write for owner, read for everybody else
chmod("/my_image_directory/image_file.jpg", 0644);
0
 
minichickenCommented:
That is use
chmod("/my_image_directory/image_file.jpg", 0644);

after your move_uploaded_file(); line... in your upload image page.
0
 
RoonaanCommented:
If you have a ftp account which runs on a different serveraccount, you possibly want to use 777 or another non restrictive chmod, otherwise you're files might be blocked from ftp removal, editing etc.

-r-
0
 
ypogeios0101Author Commented:
<?php
$uploaddir = "images"; // Where you want the files to upload
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
chmod($uploaddir.'/'.$_FILES['file']['name'],0604);
echo $uploaddir.'/'.$_FILES['file']['name'];
}
?>

now it works fine
0
 
minichickenCommented:
Hi ypogeios0101

So you got it to work with chmod(); with permission 0604. With 0644 it also worked right??
Great stuff...... :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.