echo " ";
include "/home/ac/public_html/theme/{$theme[0]}.html";
?>
|
//set these variables-----------------------------------------------------------------
$path = "home/ac/public_html/user_image/"; //path to your targetfolder after your domain
$max_size = 250999; //maximum filesize
//optionally
$domain = $_SERVER["HTTP_HOST"]; //your domainname - change if necessary like "www.wza.be"
$username = $User->Username;
//------------------------------------------------------------------------------------
$user_id = $User->Id;
$image_num_check = mysql_query("SELECT id FROM user_image WHERE user_id = '$user_id'");
if(mysql_num_rows($image_num_check) < 15) {
if (!isset($_FILES['userfile'])) {
?>
} else {
$file_type = $_FILES['userfile']['type'];
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
if ($_FILES['userfile']['size']>$max_size) {
echo "File is too big ! \n"; exit; }
if ($_FILES['userfile']['type'] == "image/jpeg" || $_FILES['userfile']['type'] == "image/pjpeg") { } else {
echo "You must upload .jpg files only. your files was $file_type \n"; exit; }
function quote_smart($value)
{ //three
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = mysql_real_escape_string($value);
}
return $value;
}
$image_title = htmlspecialchars(quote_smart($_POST['image_title']));
$date = time();
$user_id = $User->Id;
$queryy = "INSERT INTO user_image(image_title, image_about, date, user_id, username) VALUES('$image_title', '$image_about', '$date', '$user_id', '$username')";
$result = mysql_query($queryy) or die ("Error in query: $queryx. " . mysql_error());
$id_check = mysql_query("SELECT id FROM user_image WHERE id > 0 ORDER BY id DESC LIMIT 1");
$rownum = mysql_fetch_object($id_check);
$namenum = $rownum->id;
$res = copy($_FILES['userfile']['tmp_name'], "/".$path .$namenum.'.jpg');
$image = getimagesize($_FILES['userfile']['tmp_name']);
$tn_maxw = 100;
$tn_maxh = 100;
if ($image[0] > $image[1]) { $divisor = $tn_maxw / $image[0]; } else { $divisor = $tn_maxh / $image[1]; }
$n_width = $image[0] * $divisor;
$n_height = $image[1] * $divisor;
$tsrc="/home/ac/public_html/user_image/$namenum.thumb.jpg"; // Path where thumb nail image will be stored
if($_FILES['userfile']['type'] == "image/jpeg" || $_FILES['userfile']['type'] == "image/pjpeg"){
$im=ImageCreateFromJPEG($_FILES['userfile']['tmp_name']);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
if (!$res) { echo "Didn't work, please try again \n"; exit; }
echo "Image successfully Uploaded.";
echo " ";
echo "Name: $namenum.jpg \n";
echo "Size: ".$_FILES['userfile']['size']." bytes \n";
echo "Type: ".$_FILES['userfile']['type']." \n";
echo "";
}
}
}
?> |
|
|
|