Miscellaneous

  Home arrow Miscellaneous arrow Uploading Files with Forms and PHP
MISCELLANEOUS

Uploading Files with Forms and PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2003-09-28

    Table of Contents:
  • Uploading Files with Forms and PHP
  • PHP Code
  • Finishing it up

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Uploading Files with Forms and PHP


    (Page 1 of 3 )

    Timothy shows you how you can accept file uploads with PHP.

    Many sites allow users to upload files through an HTML form. While there are many security issues that should be addressed before allowing file uploads, the actual mechanisms to allow this are fairly easy.

    The first task is to construct an HTML form as an interface for a user to upload his file:

    <form action="upload.php" method="post" enctype="multipart/form-data">
      <p>File Upload</p>
      <label for="file">File</label>
      <input type="file" name="file" id="file" /> 
      <br />
      <input type="submit" name="submit" value="Submit" />
    </form>

    You've probably noticed two differences from other forms you may have designed: the enctype attribute of the form tag and the type attribute of the input tag. The form element's enctype specifies which content-type to use when submitting information back to the server. The input element's type is used designate the input element as a file select control. You'll also notice when you view the HTML in a browser that you'll also have a "Browse" button, which is part of the file select control.

    The viewer will enter the URI of a file in the input field and a copy of the file will be sent to the server when he submits the form. When received, the file is stored temporarily on the server.

    More Miscellaneous Articles
    More By bluephoenix

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap