HOME FORUM ARTICLES TUTORIALS SCRIPTS LINKS NEWS MENTORS TOOLS REGISTER

Handling File Uploads with PHP

Originally published on Programmer Assist by ERT Mentor Srirangan

This is a minimalistic guide on how to handle file uploads using PHP and XHTML forms. Prerequisites are basic XHTML and PHP skills.

Step 1: Creating an XHTML form

A form needs to be created through which a user can select the file that needs to be uploaded and pass it on to the PHP script which uploads the file. It's a very simple form using the "input type=file" attribute.

Step 2: Processing the upload

Now comes the PHP part. The approach I use here is to make use of the move_uploaded_file()[1] and the global $_FILES variable.

Notes

References

[1] PHP Documentation

© Copyright Srirangan, 2005-2007
post to Dzone Digg this! Add to del.icio.us Googleize this Add to reddit Save to myYahoo Add to furl Add to Netvouz! Spurl this! Add to Linkroll! Save to Simpy Give if thumbs up on StumbleUpon Save to Blinklist Add to Tektag Save to Bibsonomy Submit to Tweako
Search ERT on the Tools Page

Did you know? You can discuss this article with the mentor who wrote it and others interested in the topic? You are invited to join the discussion with Go to the forum

Got a technical article or tutorial you want to publish on the Internet? Join Go to the forum in the Round Table Forum and let the Mentors know what you have. If it meets ERT standards, is factual and can help ERT visitors, then ERT Mentors and Editors can help you (without charge) polish your offering so it can be published and promoted by ERT. An article published on ERT may be read by as many as 10,000 visitors a week; promoting you, your site, and your ideas. Please note ERT does not publish re-prints; promotional handouts, or pieces consisting mainly of links. So original technical content only please. If you prefer you can email the Editor