Solved

Upload image with specific permissions

Posted on 2004-10-09
11
251 Views
Last Modified: 2008-03-06
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?
0
Comment
Question by:ypogeios0101
11 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12265398
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
 

Author Comment

by:ypogeios0101
ID: 12265416
if change the permision to read for everyone the image is displayed.
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12265424
So is it working now? by setting a read permission for everyone? You question solved?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ypogeios0101
ID: 12265429
no. i manually changed the permissions. i am looking for a way to change the permission automatically when the file is uploaded.
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12265434
try this
// Read and write for owner, read for everybody else
chmod("/my_image_directory/image_file.jpg", 0644);
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12265443
That is use
chmod("/my_image_directory/image_file.jpg", 0644);

after your move_uploaded_file(); line... in your upload image page.
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 12265488
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
 

Author Comment

by:ypogeios0101
ID: 12267180
<?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
 
LVL 12

Expert Comment

by:minichicken
ID: 12267253
Hi ypogeios0101

So you got it to work with chmod(); with permission 0604. With 0644 it also worked right??
Great stuff...... :)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12520276
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

735 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