JDT

 

FREE Downloads
Articles
Tutorials

 

Creating a Simple File Uploader Using PHP - Part 4


In this series of tutorials we will look at how to develop a simple file uploader using PHP. All of the code is freely available for download (License: GNU GPL) from this link: Download File Uploader.

In this tutorial, we will look at how to set the permissions on a folder/directory to enable the file to be stored.

In order to allow an uploaded file to be stored in a folder, you need to firstly change the permissions to allow the file to be stored, and then change the permissions back to 755. Here is some code that can be used to change the permissions on a folder.

      // Change the permissions on a directory to enable a file to
      // be moved into that directory
     
      $mod = '0777'; // permissions to be set

      // connect to FTP site
      $conn = ftp_connect("$host");
      if (!$conn)
      {
      echo 'Error: Could not connect to ftp server<br>';
      exit;
      }

      // log in to FTP site
      @ $result = ftp_login($conn, $username, $password);
      if (!$result)
      {
      echo "Error: Could not log on as $user<br>";
      ftp_quit($conn);
      exit;
      }

      // try to chmod the directory
      if (ftp_site($conn, 'CHMOD '.$mod.' '.$folder)) {
      // echo "Successfully changed persmissions to 0777\n";
      }
      else {
      echo "There was a problem changing the permissions to 0777\n";
      ftp_quit($conn);
      exit;
      }

      // close the connection
      ftp_close($conn);


<- Go to Part 3   Go to Part 5 ->







Go back to PHP Tutorials home page

Go back to Tutorials home page



Earnings Tracker is John Dixon Technology's FREE accounting / bookkeeping software tool.

Aimed at contractors and freelancers, Earnings Tracker enables you to perform bookkeeping and accounting tasks, helping you to keep track of your company's earnings and outgoings.

The software is written in PHP and MySQL and is available to use for FREE online, or as a FREE download.

Earnings Tracker can also be used simply as a dividend, corporation tax, or VAT calculator.

Need free accounting software
 


JDT

Copyright Notice for John Dixon Technology Ltd

Privacy Statement

Terms & Conditions