note 51914 added to function.imagepng

From: Date: Thu, 14 Apr 2005 19:11:21 +0000
Subject: note 51914 added to function.imagepng
Groups: php.notes 
Request: Send a blank email to php-notes+get-88029@lists.php.net to get a copy of this message
To cbrasho at yahoo dot com I have read your note and the note that was made in reply. My SIMPLE solution is to add a key to each image record in the database so that the ID+Key pair will be used very similarly to a Username+Password pair =) all you have to do is create a unique random number or something to put in the "Key" field of the database when the entry is made. i've modified the code and pasted it here... <?php //get file ID+Key $id = $_REQUEST['id']; $key = $_REQUEST['key']; // i added this! //get data from blob $sql = "SELECT Data, Type, Extension FROM Images WHERE ID=$id AND Key=$key"; // this is the clever bit =D $records=mysql_query($sql); $record=mysql_fetch_row($records); $data=$record['Data']; $type=$record['Type']; $ext=$record['Extension']; //output data header("Content-Type: $type"); header("Content-Disposition: inline; filename=img$id.$ext"); echo $data; ?> all i did was add 1 line and change another =D now if "image.php?id=1&key=A29F1X" gives a result, "image.php?id=2&key=A29F1X" will output an image of zero bytes in size because the keys in the database are unique =) ---- Manual Page -- http://www.php.net/manual/en/function.imagepng.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51914 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51914&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51914&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51914&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51914&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51914&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51914&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88029) next »