They aren't really handles (whatever a handle might be) they are simply copies of the data from the $_FILES array so you can use $imageName instead of $_FILES['photo_file']['name'] everywhere throughout the rest of the script.
-Rasmus On Fri, 13 Dec 2002 [EMAIL PROTECTED] wrote: > The following is a script from the php.net site for supposedly uploading files via >ftp. My question is, why do we have to build handles, what is the purpose of >creating this array? > > //Build handles for uploaded image > $imageUpFile = $_FILES['photo_file']['tmp_name']; > $imageType = $_FILES['photo_file']['type']; > $imageName = $_FILES['photo_file']['name']; > > //Open the uploaded pic (temp file) > if ($thePic = fopen ($imageUpFile, "rb")) > { > //read temp file into var > $savePic = fread($thePic, filesize($imageUpFile)); > > //Open a new file in the correct directory using the name of the uploaded pic file > if ($fileHandle = fopen("ftp://username:password@put/directory/here/$imageName", >"w")) > { > //Put data into just opened file pointer > if (fwrite ($fileHandle, $savePic)) > { > echo "file <b>$imageName</b> successfully written"; > } > else > { > echo "file <b>$imageName</b> was NOT written"; > } > } > fclose ($fileHandle); > fclose ($thePic); > } > else > { > // The file was not created. Inform the user. > echo ("<b> The file: $imageUpFile could not be created!</b> > "); > } > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php