Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 874803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:09:48+00:00 2026-05-15T11:09:48+00:00

I have developed a small web app. This app allows users to upload images.

  • 0

I have developed a small web app.

This app allows users to upload images.
It also produces text files with the names of those images (the names are stored and retrieved to/from an MySQL Database.)

I have developed this app using MAMP. To create the uploaded image files I use the PHP function

imagejpeg('my/path/name.jpg')

and to delete the files I use the PHP function

unlink('folder1/folder2/name.jpg')

to write to the text document I am using the function

fopen('folder1/folder2/name.txt', 'w')

all three of these functions produce errors related to permissions – now the site has been moved to a live hosting environment.

Why is this? and what permissions do I need to set the folder’s folder1 and folder2 to?

I know that permission 777 is generally bad because it opens up your server to the public. However what I have found is that the functions fail to work unless I use 777 on the folders. Can anyone shed any light on my dilemma?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:09:49+00:00Added an answer on May 15, 2026 at 11:09 am

    Do not blindly set the folder’s permissions to 777, that enables the read,write,execute bits to every user on the system.

    You should always grant the least amount of privileges required for your application to run as an general security precaution.

    I don’t know much about your application’s requirements from your question above, but it seems the culprit directories only need read/write/execute permissions for you and the user that the web server runs as. You can simply grant them to the web user and then use sudo to access them yourself.

    read – so you can get a directory listing.
    write – create new or delete existing files in the directory or rename files. (eg: usage of the unlink() function)
    execute – so you can change into and access the directory.

    In your case, the following should work fine:

    chown -R www-data: folder1/
    chmod 700 folder1/ folder1/folder2/

    This is assuming your web server is running as the user www-data. If you want to have access to the directories and their respective files via FTP or a bash shell without the use of sudo, you’ll need to create a group such as wwwusers and add everyone who needs access to those directory in that group. Then do something like:

    chown -R www-data:wwwusers folder1/
    chmod 770 folder1/ folder1/folder2/

    By the way, my response is naive in that I’m assuming you have root on the server and that there isn’t anything like POSIX ACLs enabled or something such as grsecurity. With ACLs, you would need to do something such as setfacl -mu:www-data:rwx /path/to/dir. In that event, you will most likely need to seek assistance from your hosting provider.

    You really should understand the fundamentals of how permissions works on directories and files on a unix or unix-like filesystem. Make sure you run man chmod, man chown. You can also learn more here on UNIX permissions and here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have developed our website(Business users website) in .net Framework 2.0 Our client us
I am a rookie learning to develop web sites. To this point I have
I have created a very small android app. I don't want to publish it
We have a small 3 developer team that is currently using Subversion for our
I have a small calculator that I am creating in C# (Sharp Develop). The
I have developed some classes with similar behavior, they all implement the same interface.
I have developed some custom DAO-like classes to meet some very specialized requirements for
I have developed a VB.NET WCF service that recives and sends back data. When
We have developed a website that uses MVC, C#, and jQuery. In one of
We have developed a webservice that sits and runs in the context of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.