problem in writing to a file (URGENT)

Posted on 2006-04-06
Last Modified: 2008-03-06
I need to write to a file however i am not being able to do so. I can create a file and later write to it however when I try to write to an existing file then I am not allowed to. The thing is everything works in localhost ...its when I keep it in the server that the problem starts coming. I believe this has got to do something with the permission so I changed the permission to read,write, execute for all (user/group/other) but then it didnt help. Does anyone have any idea on this ?
Question by:Sid123
    LVL 10

    Accepted Solution

    Change the file permission to 777 OR you may need to change the folder that actually contains the file, try and change that to 777 as well.

    Note - 777 is really not a good idea however it IS a quick fix to see if thats the problem.
    LVL 10

    Expert Comment

    See here about file security (777 permissions)
    LVL 6

    Expert Comment

    > when I try to write to an existing file then I am not allowed to.

    What do you mean?  Do you see an error message?  What's the message?  How are you writing to the file?  fopen() fwrite()?

    > I changed the permission to read,write, execute for all
    > (user/group/other) but then it didnt help.

    I believe that's what wildzero was suggesting.
    How did you change the file permission?
    Did you use the PHP chmod() function or did you use the linux 'chmod 777' command?
    Who is the owner of the file?
    LVL 4

    Expert Comment

    Although unlink(..)ing a not needed file before writing to it may help.
    Of course you'd have to have the right permissions (unless it's a totally esoteric problem created by the server your script / page runs on) ;).


    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    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…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to dynamically set the form action using jQuery.

    731 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

    18 Experts available now in Live!

    Get 1:1 Help Now