Location: PHPKode > projects > Library Accounting System > library/movie_module/m_edit_image.php
<HTML>
<HEAD>
</HEAD>
<BODY>
<?
        $url_blocker = "75726C00";
        include "./languages/l_eng.php";
        include "connect.php";
        $refurl = $_REQUEST['doing'];

if($_FILES['userfile']['size'] > 0){
    mysql_query("DELETE FROM `images` WHERE refurl = '$refurl'");
        $tmpName  = $_FILES['userfile']['tmp_name'];
	$filetype = $_FILES['userfile']['type'];
	$fp      = fopen($tmpName, 'r');
	$content = fread($fp, filesize($tmpName));
	$content = addslashes($content);
	fclose($fp);
        mysql_query("INSERT INTO `images` (`refurl`,`type`, `content` ) VALUES ('$refurl', '$filetype', '$content')") or die(mysql_error());
	
}elseif ($_REQUEST['url'] == "auto"){
    mysql_query("DELETE FROM `images` WHERE refurl = '$refurl'");
  $isbn = mysql_fetch_array(mysql_query("SELECT isbn FROM `printed` WHERE refurl = '$refurl'"));
  
$image = addslashes(file_get_contents("http://images.amazon.com/images/P/".strtoupper($isbn['isbn']).".01._SCMZZZZZZZ_.jpg"));

 if (strlen ($image) > 1051){
mysql_query("INSERT INTO `images` (`refurl`,`type`, `content` ) VALUES ('$refurl', 'image/jpg', '$image')") or die(mysql_error());
}
}elseif ($_REQUEST['url'] != ""){
    mysql_query("DELETE FROM `images` WHERE refurl = '$refurl'");
 $image = addslashes(file_get_contents("$_REQUEST[url]"));
$file = explode(".", $_REQUEST['url']);
$filetype = "image/".array_pop($file);

    if (strlen ($image) > 1051){
    mysql_query("INSERT INTO `images` (`refurl`,`type`, `content` ) VALUES ('$refurl', '$filetype', '$image')") or die(mysql_error());
}
}


?>		


        <form action="edit_image.php" enctype="multipart/form-data" name ="form1" method="post">
        <input type="hidden" name="doing" value= "<?=$refurl?>" />
        <table cellpadding="0" cellspacing="0" align="center" width="95%" class="forText">
        <tr><td align="left"><?=$lang_['image']?></td>
        <td align="left"> <img src="images.php?doing=<?=$refurl?>"></img><br /></td>
        <tr><td align="left"><?=$lang_['upimage']?></td>
        <td align="left"><span id = "userfile1" class="combow"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000" /><input name="userfile" type="file" /></td></tr>

        <tr><td align="left"><?=$lang_['urlimage']?></td><td align="left"><input type="text" name="url"/></td></tr>
        <tr><td align="center" ><input type="submit" value="<?=$lang_['submit']?>"/></td></tr>
        </table></form>

      </BODY>
</HTML>
Return current item: Library Accounting System