PHP
  Home arrow PHP arrow Defining a Custom Function for File Uploaders with PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT