Solved

Upload image with specific permissions

Posted on 2004-10-09
11
247 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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 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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now