note 65955 added to function.file-exists

From: Date: Wed, 10 May 2006 19:04:13 +0000
Subject: note 65955 added to function.file-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-111082@lists.php.net to get a copy of this message
The following code will rename an uploaded image to a MD5 hash with a rand number added of its name and check wheter a file with same hash already exists or not: <?php $file = $HTTP_POST_FILES['file']; $image=new Image($imgfld,$file); if($image->FType != null){ if ($image->FType=="image/gif") { $ext = ".gif"; }else{ $ext = ".jpg"; } $nfile = md5($image->Name . rand()); while(file_exists($imgfld . $nfile . $ext) == true){ $nfile = md5($image->Name . rand()); } $image->ResizedWidth = $imggrx; $image->ResizedHeight = $imggry; $image->Resample($nfile); ?> It uses an image class found at phpclasses.org ---- Server IP: 81.92.200.26 Probable Submitter: 85.241.115.146 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.file-exists.php Edit -- http://master.php.net/note/edit/65955 Del: integrated -- http://master.php.net/note/delete/65955/integrated Del: useless -- http://master.php.net/note/delete/65955/useless Del: bad code -- http://master.php.net/note/delete/65955/bad+code Del: spam -- http://master.php.net/note/delete/65955/spam Del: non-english -- http://master.php.net/note/delete/65955/non-english Del: in docs -- http://master.php.net/note/delete/65955/in+docs Del: other reasons-- http://master.php.net/note/delete/65955 Reject -- http://master.php.net/note/reject/65955 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111082) next »