Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Learning PHP, Part 2: Upload files and use XML to store and display file information

Tyler Anderson (tyleranderson5@yahoo.com), Engineer, Stexar Corp.
Tyler Anderson graduated with a degree in computer science from Brigham Young University in 2004 and is currently in his last year as a master's of science student in computer engineering. In the past, he worked as a database programmer for DPMG.com, and he is currently an engineer for Stexar Corp. in Beaverton, Ore.
Nicholas Chase (ibmquestions@nicholaschase.com), Web Developer, Freelance Developer
Nicholas Chase has been involved in Web-site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. He has been a high school physics teacher, a low-level- radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, an Oracle instructor, and the chief technology officer of an interactive communications company. He is the author of several books, including XML Primer Plus (Sams, 2002).

Summary:  This tutorial is Part 2 of a three-part "Learning PHP" series teaching you how to use PHP through building a simple workflow application. Take this tutorial if you have a basic understanding of PHP and want to learn about uploading files from the browser, sessions, or using PHP to process XML.

View more content in this series

Date:  21 Jun 2005
Level:  Intermediate PDF:  A4 and Letter (384 KB | 37 pages)Get Adobe® Reader®

Activity:  20163 views
Comments:  

Before you start

About this tutorial

This tutorial teaches you how to use PHP by demonstrating the construction of a Web-based workflow application. "Learning PHP, Part 1" covered the basics, such as syntax, functions, working with HTML forms submissions and databases, and creating a process by which a new user can register for an account.

In this tutorial, you're going to enable users to upload files to the system by using their browsers, and you're going to use XML to store and display information about each file.

Part 3 looks at using HTTP authentication, as well as protecting files by streaming them from a non-Web-accessible directory. You'll also look at creating objects and using exceptions.

In the course of this tutorial, you'll examine:

  • Creating and using sessions and session information.
  • Uploading files from the browser.
  • Creating XML using the Document Object Model (DOM).
  • Manipulating XML data using DOM.
  • Creating a Simple API for XML (SAX) content handler.
  • Reading XML data using SAX.

Who should take this tutorial?

This tutorial is Part 2 in a three-part series designed to teach you the various aspects of working with PHP while building a workflow application. Take this tutorial if you have a basic understanding of PHP and want to learn about uploading files from the browser, sessions, or using PHP to process XML.

This tutorial assumes a basic familiarity with PHP to the level discussed in Part 1 of this series. That includes basic understanding of control structures, such as loops and if-then statements, as well as functions, and working with HTML forms submissions and databases. Familiarity with XML is helpful, but not required. (You can find more information about these topics in Resources.)


Prerequisites

To follow along, you need a Web server, PHP, and a database installed and available. Unless you will be using an external hosting account, download and install the following packages:

Web server -- Whether you're on Windows® or Linux® (or Mac OS X, for that matter), you have the option of using the Apache Web server. Feel free to choose V1.3 or V2.0, but the instructions in this tutorial will concentrate on 2.0. Download Apache. If you're on Windows, you also can use Internet Information Services, which is part of Windows.

PHP -- Of course, you will also need a distribution of PHP. Both PHP V4 and PHP V5 are in use at the time of this writing, but because of changes in PHP V5, we'll concentrate on that version. (The version isn't terribly important in this tutorial, but it makes a difference for the last part of this series.) Download PHP.

Database -- Part of this project involves saving data to a database, so you'll need one of those, as well. In this tutorial, we'll concentrate on MySQL because it's so commonly used with PHP. Download MySQL.

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=133660
TutorialTitle=Learning PHP, Part 2: Upload files and use XML to store and display file information
publish-date=06212005
author1-email=tyleranderson5@yahoo.com
author1-email-cc=troy@backstopmedia.com
author2-email=ibmquestions@nicholaschase.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers