1. About.com
  2. Computing & Technology
  3. PHP / MySQL

Discuss in my forum

Renaming PHP Uploads

By , About.com Guide

Finding the Extention
Next we will use a function explained here, to look at the file name and take off the extension for us to use later when we reassign it a new name.
 <?php //This function separates the extension from the rest of the file name and returns it  function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file  $ext = findexts ($_FILES['uploaded']['name']) ; 

©2012 About.com. All rights reserved. 

A part of The New York Times Company.