O'Reilly logo

PHP for Teens by Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Allowing File Uploads

You want a way for readers to communicate with you through your web site. This is commonly done through email, but sometimes the visitor may want to send something—a picture or a music file, perhaps. PHP allows you to upload a file through a form and send it to the web server. Let’s take a look at how to do this.

Remember that when using forms you can choose either GET or POST. PHP file uploading works best with POST.

HTML Program

I’ve created the form that allows for selecting a file. This one allows you to select a file from anywhere on your computer, and then it creates a submit button that lets the visitor send the file through the browser. Check out the code that makes this happen, then look at Figure 14.1.

Figure ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required