note 77635 added to function.sha1-file

From: Date: Thu, 06 Sep 2007 14:02:44 +0000
Subject: note 77635 added to function.sha1-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-130256@lists.php.net to get a copy of this message
If you've got a script that allows user file upload, and you want to prevent multiple uploads of the same file: <? session_start(); $isDuplicate = false; if(isset($_FILES["filename"]["tmp_name"]) && file_exists($_FILES["filename"]["tmp_name"])) { $fileHash = sha1_file($_FILES["filename"]["tmp_name"]); if(!isset($_SESSION["check_filelist"])) { $_SESSION["check_filelist"] = array($fileHash); } elseif(in_array($fileHash,$_SESSION["check_filelist"])) { $isDuplicate = true; } else { $_SESSION["check_filelist"][] = $fileHash; } if($isDuplicate) { echo "You've already uploaded that file"; } else{ // do some stuff } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 63.174.231.179 ---- Manual Page -- http://www.php.net/manual/en/function.sha1-file.php Edit -- https://master.php.net/note/edit/77635 Del: integrated -- https://master.php.net/note/delete/77635/integrated Del: useless -- https://master.php.net/note/delete/77635/useless Del: bad code -- https://master.php.net/note/delete/77635/bad+code Del: spam -- https://master.php.net/note/delete/77635/spam Del: non-english -- https://master.php.net/note/delete/77635/non-english Del: in docs -- https://master.php.net/note/delete/77635/in+docs Del: other reasons-- https://master.php.net/note/delete/77635 Reject -- https://master.php.net/note/reject/77635 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130256) next »