Hi Steve,
If "img" was the "name" field of your <INPUT TYPE="FILE"> tag, then:
$img is pointer to the temporary file uploaded by the web server. You can pass this value into your function as you have done, but you can also specify that it is a GLOBAL var inside your function. This goes for all the $img_ variables you are using inside your function, too. Either pass them *ALL in as parms, or declare them all as GLOBAL.
You are also checking:
if ($img != 'none') {}
I don't know how the value would ever get to be 'none'. To see if the user did not upload a file (depending on your web server), check:
if (is_set($img)) {}
or
if (!empty($img_name)) {}
I have found the second one to be more universal as some web servers will set the variable just because it was in the form. If you have PHP >= 4.0.2, an even better solution is to check:
if (!is_uploaded_file($img)) {}
You later set $img="" if the copy fails. Don't. Just send an error and unlink() it at the end of your script.
Aaaand...
Although I might get flamed for this opinion, I think it is bad form to have a function exit unless it is an explicit exit function. In your case, it is probably better to return 0 or 1 depending on the failure or success of the copy. This way, your function can be used like:
if (getImage()) {
print "Success!";
}
else {
print "Failure!";
}
If you wanted to get even fancier, you could return various degrees of values <0 to indicate the type or reason for the failure.
For more excruciating detail on uploading files:
http://www.php.net/manual/en/features.file-upload.php
HTH
-- Rich Rijnders
-- Irvine, CA US