Solved

Upload image with specific permissions

Posted on 2004-10-09
11
248 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

785 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