PHP File Uploading

Posted on 2004-11-15
Last Modified: 2006-11-17

I have a script which allows users to upload files through a web form to my server, however, I realised that all the files that are uploaded have a default permission attribute of "600". These files should actually be viewable by the user, which means it should be uploaded to a "644" permission.

Can someone advice me if this default permission attribute have to be made server side, or am I doing something wrong with my scripts?
Question by:lifegauge
    LVL 5

    Accepted Solution

    after uploading set the permission right with the PHP funtion CHMOD:

    Assisted Solution

    You could do a chmod on it just as php-webdesign has mentioned, but it would be better to set default permissions on the directory to which you're writing and for the user who is doing the writing.  Chmod is great but for security purposes, it would be better to config on the server instead of making PHP do the work.

    If you are using a Linux web server you need to find out which user is writing the files (sometimes apache, sometimes nobody - depends on how the server has been config'd).  Then you can change the user's umask so that any files they write use the default permissions you've set.
    LVL 5

    Expert Comment

    i know... but the CHMOD way of PHP is good to work with if you haven't got full access to the server. but if you do have full access your way is bether :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 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

    17 Experts available now in Live!

    Get 1:1 Help Now