PHP
  Home arrow PHP arrow Defining a Custom Function for File Up...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Defining a Custom Function for File Uploaders with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-09

    Table of Contents:
  • Defining a Custom Function for File Uploaders with PHP 5
  • The full source code of the previous file uploading application
  • Putting the file uploading script into the “uploadFile()” custom PHP function
  • Putting the uploadFile() PHP custom function to work

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Lose your application development headaches. Start developing and deploying applications with Advantage Database Server today. Download a 30-day trial for Free!

    Defining a Custom Function for File Uploaders with PHP 5
    (Page 1 of 4 )

    In the next few lines I’m going to show you how to wrap the file uploading application built in the previous article of the series into a single custom PHP function. This will turn it into a more maintainable and reusable piece of code.

    Learning how to implement file uploads with PHP is undoubtedly one of those things that you have to tackle sooner or later, during your life as PHP developer. And if you’re not armed with a decent background on this topic, there’s the possibility that by the time you finish building your first file uploading application, you will have suffered serious hair loss.

    However, there’s no need to expect this, since in this series of articles, you’ll find the right pointers to help you start implementing file uploads with PHP 5. And as always, you’ll be provided with copious practical examples that will help you understand this useful topic from a hands-on point of view.

    Now that you’ve been introduced to the principal subject of this article series, let me quickly rehash the items that I discussed in the preceding installment, in case you haven’t read it yet. In the course of the mentioned tutorial, I went through the development of a basic error handling module that came in handy for keeping track of all the errors that might occur during a specific file uploading process.

    What’s more, the logic implemented by this simple error checking module was built around the functionality provided by the $_FILES super global PHP array, since it uses one of its elements to store different error codes that are associated with a particular file uploading failure. In this way, it was pretty simple to instruct the module in question to throw several exceptions that could be neatly caught by a typical “try-catch()” block.

    So far, so good. At this point, I should assume that building an error checking mechanism that is aimed at tracking all the failures that might arise when uploading a selected file to a web server, is now a familiar process to you. Therefore, it’s time to introduce a few other improvements to the pertinent file uploading application that you learned in the previous tutorial.

    Let’s continue this educational journey now!

    More PHP Articles
    More By Alejandro Gervasio


       · Over the course of this fourth part of the series, the file uploading application...
     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway