Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Upload image with specific permissions

Posted on 2004-10-09
11
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
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…
The viewer will learn how to count occurrences of each item in an array.

722 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