A question, which should eventually be appended to http://drupal.org/node/117054.
In the MySite Icon module (part of http://drupal.org/project/mysite -- available in HEAD), I allow administrators to upload image files.
My understanding is that the file uploads are written to the /tmp directory by the FormsAPI and then validated. For instance, I run this code, taken from user.module, to ensure that the upload is in fact an image:
// Check that uploaded file is an image
$info = image_get_info($file->filepath);
if (!$info || !$info['extension']) {
form_set_error('icon', t('The uploaded file was not an image.'));
}
If this succeeds, I then move the file into the proper /files directory.
My naive question: If the $info check fails, do I need to expressly delete the file from the /tmp directory, or does that happen automatically as part of the upload process?
For reference, here's the entire validation function:
<?php
function mysite_icon_validate_picture($file, &$form_values, $form_element = 'icon') {
// get the size restrictions
list($maxwidth, $maxheight) = explode('x', variable_get('mysite_icon_dimensions', '120x60'));
$size = variable_get('mysite_icon_file_size', 32);
// Check that uploaded file is an image
$info = image_get_info($file->filepath);
if (!$info || !$info['extension']) {