Thumb help please!

SpaceshipSpaceship
Watch

shanee86

Established Member
Impact
2
Hello I am and have been trying for a long time to mod my image host to make a thumb and then a page were they can view the image in full like other site's. I got the image view page but need help with making the thumb im my code. I found another script for a image host that makes a thumb and tryed adding it to my page and can't get it right. Anyway here is the code for new script:

<?
include "config.php";

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }
if(($HTTP_POST_FILES['userfile']['type']=="image/gif") ||
($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") ||
($HTTP_POST_FILES['userfile']['type']=="image/JPEG") ||
($HTTP_POST_FILES['userfile']['type']=="image/png")) {

if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; }

//generate random number
$zufall = rand(1,9999);
$fupl = "$zufall";

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "./".$path .$fupl .$HTTP_POST_FILES['userfile']['name']);

if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else {
?>
<br>

<?
//set url variable
$domst = "";
$drecks = "/";
$imgf = $fupl.$HTTP_POST_FILES['userfile']['name'];
$thbf = $tpath.$imgf;
$urlf = $domst .$domain .$drecks .$path .$imgf;


//create thumbnails
function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
if (preg_match('/jpg|jpeg|JPG|JPEG|jpg/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png|PNG/',$system[1])){
$src_img=imagecreatefrompng($name);
}
if (preg_match('/gif|GIF/',$system[1])){
$src_img=imagecreatefromgif($name);
}

$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}

$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);


if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
}
if (preg_match("/gif/",$system[1]))
{
imagegif($dst_img,$filename);
}
else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}

createthumb($path.$imgf,$tpath.$imgf,$tsize,$tsize);
?>


<body bgcolor="#ffffff">
<center>
<div class="support" id="agreement">
<table border='0' >
<link rel="STYLESHEET" type="text/css" href="style.css">
<FORM action="nowhere" method="post"><title><? echo $company; ?></title>
<center>

<tr><td>Forum/MySpace:</td><td><input type="text" name="thetext" size="60" value=""></td></tr>



<tr><td>URL:</td><td><input type="text" name="thetext" size="60" value='<? echo $domst .$domain .$drecks ?>image.php?id=<? echo $imgf; ?>'></td></tr>
<tr><td>DIRECT URL:</td><td><input type="text" name="thetext" size="60" value="<? echo $urlf; ?>"></td></tr>
<tr><td>HTML:</td><td><input type="text" name="thetext" size="60" value="<a href='<? echo $domst .$domain .$drecks; ?>image.php?id=<? echo $imgf; ?>'><img src='<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>'></a>"></td></tr>
<tr><td>BBCode:</td><td><input type="text" name="thetext" size="60" value=""></td></tr>
<tr><td>IMAGE:</td><td>



<a href="<? echo $domst .$domain .$drecks; ?>image.php?id=<? echo $imgf; ?>" target="_self"><img border="0" src="<? echo $thbf ?>" width="88" height="31" alt="<? echo $site ?>"></a> - Click to enlarge.


</td></br>
<a href="javascript:history.go(-1);" title="go back to previous page">Back</a> </div></tr></td></tr>
<?

}
} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><link rel='stylesheet' href='style.css' type='text/css'><div class='support' id='agreement'><p><center>Sorry We do not support the file type!</font></center></div><br>\n"; exit; }
}
?>
</table>
<br><br>
</body>


My current upload page is:

<?
include("include/common.php");
include("include/header.php");
if($loggedin){
include("include/accmenu.php");
}
if( $_POST['submit'] && $_FILES['attached']['name'] ){
$ok_filetypes = explode("|",$att_filetypes);
if (!$_FILES['attached']['error'] && $_FILES['attached']['size'] > $att_max_size*1024){
errform('<CENTER>Sorry, but the attached file is too large. Please reduce the size of it\'s contents.</CENTER><BR><BR>'); // #err
$step = 1;
}
$filename = (!$_FILES['attached']['error'] ? substr( basename($_FILES['attached']['name']), -30 ) : '');
$x = strtolower( substr($_FILES['attached']['name'], -3));
if($filename && !in_array($x, $ok_filetypes) ){
errform('<CENTER>Sorry, the filetype you have tried to upload is not allowed.</CENTER><BR><BR>');
$step = 1;
}
if(!$posterr){
if(!isset($_GET["ipaddress"]) || ($_GET["ipaddress"] == "")) {
$ipaddress = $_SERVER['REMOTE_ADDR'];
$local = 1;
} else {
$ipaddress = $_GET["ipaddress"];
$local = 0;
}
$uniq = substr( md5(uniqid (rand())), 0, 10 );
$ext = strtolower( substr($_FILES['attached']['name'], -3));
move_uploaded_file($_FILES['attached']['tmp_name'], $att_path."/".$uniq.".".$ext );
$strQuery = "INSERT INTO images SET ";
$strQuery .= "filename='".$uniq.".".$ext."',";
$strQuery .= "ipaddress='{$ipaddress}',";
$strQuery .= "date='".time()."',";
$strQuery .= "pkey='{$uniq}',";
if($myuid){
$strQuery .= "user='{$myuid}',";
}
$strQuery .= "status='1'";
$result = mysql_query($strQuery) or die( mysql_error() );
$aid = mysql_insert_id();
if($aid){
$filen = $siteurl."/".str_replace('./', '', $att_path)."/".$uniq.".".$ext;
$filen = str_replace('http://','%%',$filen);
$filen = str_replace('//','/',$filen);
$filen = str_replace('%%','http://',$filen);
$step = 2;
}else{
$step = 1;
}
}
}else{
$step = 1;
}
if($step == 1){
?>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-8643130717389440";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="0405934408";
google_color_border = "B0E0E6";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "336699";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align=center>
<form ENCTYPE="multipart/form-data" method="post" name="form1">
<INPUT NAME="attached" TYPE="file" size="50"><br>
File extensions allowed: <b><?=implode("</b>, <b>",explode("|",$att_filetypes))?></b><br>
File size limit: <b><?=$att_max_size?>KB</b>
<br><br>
<input type="submit" name="submit" value="Upload Image">
</form>
<script type="text/javascript"><!--
google_ad_client = "pub-8643130717389440";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="0405934408";
google_color_border = "B0E0E6";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "336699";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</td>
</tr>
</table>
<?
}else{ ?>
<div align="center"><b>Your image has been successfully uploaded!</b><br>
<br><script type="text/javascript"><!--
google_ad_client = "pub-8643130717389440";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="0405934408";
google_color_border = "B0E0E6";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "336699";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><img src="<?=$filen?>"></p>
<p> <script type="text/javascript"><!--
google_ad_client = "pub-8643130717389440";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="0405934408";
google_color_border = "B0E0E6";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "336699";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><!-- PayPopup.com Advertising Code Begin -->

<div id="PaypopupStartCode" style="display:none">
</div>
<script language="JavaScript1.1">
if (typeof(paypopupScriptStart) == 'undefined') {var paypopupScriptStart = false;}
if (!paypopupScriptStart) {
document.write('<scr'+'ipt src="http://popunder.adsrevenue.net/popup.php?'+(new Date()).getTime()+'&id=shanee86&pop=enter&t=2&subid=31970&blk=1&fc=-1"></scr'+'ipt>');
paypopupScriptStart = true;
}
</script>
<noscript>
<div style="width: 1px; height: 1px;overflow: hidden;"><a href="http://www.paypopup.com">Online Advertising</a></div>
</noscript>

<!-- PayPopup.com Advertising Code End --></p>
</div></td>
</tr>
<tr>
<td><div align="center"><br>
To insert this image in a message board post copy and paste the following
code:<br>
<textarea name="textarea" cols="100" wrap="soft" rows="3"></textarea>
</div></td>
</tr>
<tr>
<td><div align="center"><br>
To send this image to friends and family, copy and paste this code: <br>
<textarea name="textarea2" cols="100" rows="4"><?=$filen?></textarea>
</div></td>
</tr>
<tr>
<td><div align="center"><br>
To insert this image using HTML, copy and paste the following
code:<br>
<textarea name="textarea3" cols="100" wrap="soft" rows="3"><a href="<?=$siteurl?>" target="_blank"><img alt="Image Hosted by <?=$sitename?>" src="<?=$filen?>" /></a></textarea>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<? } ?>
<?
include("include/footer.php");
?>

I tried adding the code under this is to make thumb but didn't work please help thanks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back