Variable Variables & File Attributes

From: Date: Wed, 02 Aug 2000 22:56:30 +0000
Subject: Variable Variables & File Attributes
Groups: php.general 
Request: Send a blank email to php-general+get-9843@lists.php.net to get a copy of this message
Hello all: I have the following code that will eventually handled a selection of uploaded files. The variable name for the uploaded files is a variable and while I've been able to work with the file to copy it I have been unable to access any of the attributes such as $file_type or $file_size. I need to be able to validate the files base on both file type and size. Any suggestions would be greatly appreciated. Chad <code> require ("copyimages.phtml"); $images_available = array("north", "south", "east", "west", "front"); // the items in this array are used as the "name" for files uploaded in a // form that this script is handling. $number_images = count($images_available); for ($i = 0; $i < $number_images; $i++){ $file = $images_available[$i]; copy_images(${$file}, $images_available[$i], $id); // $id was previously retrieved from a mySQL Database } } </code> <code> #copyimages.phtml function copy_images($file, $image, $id){ $file_location = "../images/"; $file_name = $id . "_" . $image . ".jpg"; if ($file_size == "image/jpeg"){ //evaluates false even if it is a jpeg if ($file != "none"){ copy($file, "$file_location$file_name"); //works fine } } } </code>

« previous php.general (#9843) next »