Will You Add?
#1 in Business Subscribe Email Print

You are here: Home > Internet and Businesses Online > Web Development > Using PHP to Change the Permissions on a Folder

Tags

  • please
  • another
  • write another
  • madethe following

  • Links

  • Finding Offshore Customers for a Call Center Startup
  • The False Housing Rebound
  • Golf Resistance Training - Helping to Make You a Better Player
  • Will You Add? - Using PHP to Change the Permissions on a Folder

    Want To Make Money Online? You Need To Sell What People Are Buying
    For several years now, enterprising individuals like you have been trying to make money on the Internet. It’s flexible, low-cost, and if you do it right, can be extremely profitable. If you’re among those who have tried to succeed and have not yet found that magic formula, you may just need to re-evaluate what you’re trying to s
    to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    No Dollar, No Client?
    You are now a business owner, congratulations! You have everything you need right down to the business plan but one thing is missing. Customers. As you sit in the darkness of your living room at night, you wonder how you can afford to advertise and where.The next morning you drag out the Yellow Pages looking for a company t
    Sometimes it's useful to enable visitors to your site to upload content, for example, photos, which can then be displayed on the site.

    Folders on a website, for example, an images folder will typically have permissions of 755, which means that normal visitors to the site will be unable to upload content into the folder. They will receive an error message when they try to do so.

    In order to allow the upload, one solution is to temporarily change the permissions on the folder to 777 before the upload is made, and then to change them back to 755 after the upload has been made.

    The following PHP script shows how you can do this using PHP's ftp_site command. This script only changes the permissions one way (to 777), it doesn't change them back. You would need to extend the script or write another one to do this. The line that reads $mod = '0777'; // permissions to be set is the one that determines what the permissions are going to be set to.

    Note: Please remove the space between the '<' and '?php' at the beginning of the script, and the '?' and '>' at the end of the script.

    < ?php

    // Set up variables
    $host = 'www.xyz.com'; // host (website) that contains the folder you want to change
    $user = 'username'; // username to log onto the host
    $password = 'password'; // password to log onto the host
    $folder = 'public_html/test/'; // folder name to change
    $mod = '0777'; // permissions to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    f

    Traffic Building - Is Traffic Passing You By?
    Traffic is the life blood necessary for the success of profiting from your website. When I first got interested in starting a business I knew nothing about traffic. All I had heard about were websites and product. I had the same opinion as others, build a nice website. find a good product and voila, instant riches.Once I go
    n they try to do so.

    In order to allow the upload, one solution is to temporarily change the permissions on the folder to 777 before the upload is made, and then to change them back to 755 after the upload has been made.

    The following PHP script shows how you can do this using PHP's ftp_site command. This script only changes the permissions one way (to 777), it doesn't change them back. You would need to extend the script or write another one to do this. The line that reads $mod = '0777'; // permissions to be set is the one that determines what the permissions are going to be set to.

    Note: Please remove the space between the '<' and '?php' at the beginning of the script, and the '?' and '>' at the end of the script.

    < ?php

    // Set up variables
    $host = 'www.xyz.com'; // host (website) that contains the folder you want to change
    $user = 'username'; // username to log onto the host
    $password = 'password'; // password to log onto the host
    $folder = 'public_html/test/'; // folder name to change
    $mod = '0777'; // permissions to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    The 10 Worst Mistakes You Can Make when Selling Your Privately Owned Small Business
    Thinking about selling your business? You are not alone. CNN Money reports that 35 million baby boomers are expected to retire between 2000 and 2020. If you are approaching retirement or soon will be, chances are you’ve considered putting your business on the market for one of the following reasons:• You feel burned out;777), it doesn't change them back. You would need to extend the script or write another one to do this. The line that reads $mod = '0777'; // permissions to be set is the one that determines what the permissions are going to be set to.

    Note: Please remove the space between the '<' and '?php' at the beginning of the script, and the '?' and '>' at the end of the script.

    < ?php

    // Set up variables
    $host = 'www.xyz.com'; // host (website) that contains the folder you want to change
    $user = 'username'; // username to log onto the host
    $password = 'password'; // password to log onto the host
    $folder = 'public_html/test/'; // folder name to change
    $mod = '0777'; // permissions to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    How Small Businesses Can Compete With Big Corporations?
    1. Small businesses have great advantages when compared to big corporations. Small businesses can be nimble, agile and react to changes very quickly, where as big corporations have lot of systems, bureaucracies and on top of all these valid problems, they have politics. So big corporations cannot be nimble and react to changes as
    f the script.

    < ?php

    // Set up variables
    $host = 'www.xyz.com'; // host (website) that contains the folder you want to change
    $user = 'username'; // username to log onto the host
    $password = 'password'; // password to log onto the host
    $folder = 'public_html/test/'; // folder name to change
    $mod = '0777'; // permissions to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    Don't Sell Grandma's Jewelry at a Yard Sale...Get More Money
    Have some vintage jewelry? There are several ways you can sell collectible or vintage costume jewelry. How much your vintage jewelry is worth depends on several things. First and foremost, you need to know what you have and the condition it is in. Refer to our first article for helpful tips on old jewelry research. You may co
    to be set

    // connect to FTP site
    $conn = ftp_connect("$host");

    if (!$conn)
    {

    echo 'Error: Could not connect to ftp server';

    exit;
    }

    // log in to FTP site
    @ $result = ftp_login($conn, $user, $password);

    if (!$result)
    {

    echo "Error: Could not log on as $user";

    ftp_quit($conn);

    exit;
    }

    // try to change the permissions on the directory
    if (ftp_site($conn, 'CHMOD '.$mod.' '.$folder)) {

    echo "Successfully changed permissions";
    }

    else {

    echo "There was a problem changing the permissions";

    ftp_quit($conn);

    exit;
    }

    // close the connection

    ftp_close($conn);

    ? >

    The script is fairly straight forward. You initially set up a few variables for the host name and stuff like that, you then connect to the FTP site, log on to the site, change the permissions of the folder, and then finally log off.

    The path to the folder (assigned to $folder) will be something like 'public_html/.../'. Check with your ISP if you're not sure what this is.

    Have fun!

    HTTP = HTML link (for blogs, profiles,phorums):
    <a href="http://www.atriclecheck.com/article/86414/atriclecheck-Using-PHP-to-Change-the-Permissions-on-a-Folder.html">Using PHP to Change the Permissions on a Folder</a>

    BB link (for phorums):
    [url=http://www.atriclecheck.com/article/86414/atriclecheck-Using-PHP-to-Change-the-Permissions-on-a-Folder.html]Using PHP to Change the Permissions on a Folder[/url]

    Related Articles:

    How to Answer Difficult Questions in Job Interview? Use the Seek-And-Reply Technique

    How to Write a Nursing Resume

    PPC Advertising - The Hidden Cost

    Bookmark it: del.icio.us digg.com reddit.com netvouz.com google.com yahoo.com technorati.com furl.net bloglines.com socialdust.com ma.gnolia.com newsvine.com slashdot.org simpy.com shadows.com blinklist.com