
07-11-05, 08:03 PM
|
|
New Member
|
|
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
image resize
Hi everyone!! how can i resize the image uploaded if is bigger than the $maxsize?
thanks
PHP Code:
<?
include "./config.php";
if ($file && $file_name){
if ($_FILES['file']['size']>$maxsize) $status = "Error: Picture size too large. Max file size is 100 kbytes. <a href='http://mydomain.com/thumbnail.php'>Image Resizer</a><br>";
if (($_FILES['file']['type']!="image/gif") && ($_FILES['file']['type']!="image/jpeg") && ($_FILES['file']['type']!="image/jpg") && ($_FILES['file']['type']!="image/pjpeg")) $status .= "Error: Wrong file type. Must be JPG or GIF only.<br>";
$picext = substr($file_name,-3);
$picext = strtolower($picext);
if ((!$status) && ($picext!="gif") && ($picext!="jpg") && ($picext!="peg")) $status .= "Error: Wrong file type. Must be JPG or GIF only.<br>";
if (!$status){
$sql = "insert into $table values('', '$email', '$aim', '$icq', '$yahoo', '$homepage', '0', '0', '1', '0', '0', '', now())";
$result = mysql_query($sql) or die("Failed: $sql - ".mysql_error());
$sql = "select max(id) from $table";
$result = mysql_query($sql);
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
$sql = "update $table set picfile = '".$id.".".$picext."' where id='$id'";
$result = mysql_query($sql);
@copy($file, "./pics/".$id.".".$picext);
Header("Location: index.php?id=$id");
exit;
}
}
?>
|