From another discussion...


Quote Originally Posted by ScallioXTX View Post
Yes, with unlink. Just delete the uploaded file once you're done with it (stored, resized it, etc).
Without posting my entire script here, which file(s) should I be deleting?

Towards the top of my script I have...
PHP Code:
    if (empty($errors)){
        
// Valid Form Data.
        
if (empty($_FILES['userPhoto']['tmp_name'])){
            
// No File.
            
$errors['upload'] = 'Choose a File.';

        }else{
            
// File exists.
            
$tempFile $_FILES['userPhoto']['tmp_name'];
        }

    }else{
        
// Invalid Form Data.
        // Drop through to display Errors.

    
}//End of CHECK FOR FILE 

In a lot of my "upload.php" script I use $tempFile to check if the uploaded photo is "clean".

But then once I start working with GD, I am working a lot with functions which create an "Image Resource Identifier".

So what about these snippets of code...

PHP Code:
    $origImage = @imagecreatefromgif($tempFile); 
PHP Code:
    $newTrueColorImage = @imagecreatetruecolor($newWidth$newHeight); 
PHP Code:
    $resizedImage = @imagecopyresampled($newTrueColorImage$origImage0000$newWidth$newHeight$origWidth$origHeight); 
PHP Code:
    $newPhoto = @imagegif($newTrueColorImage$newFilePath); 

Follow me??

Based on my understanding of things, it seems like I need to delete either $_FILES or $_FILES['userPhoto']['tmp_name'] at the very end of my script like this...

PHP Code:
unlink($_FILES
or

PHP Code:
unlink($_FILES['userPhoto']['tmp_name']) 

But what about the intermediary "Image Resource Identifiers"??

And maybe there are some other files I am missing??

Sincerely,


Debbie