Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?
$user=$_SESSION['user'];
if(!$user){header("Location: /login.php");exit;}
else{
print'<FORM id="Upload" ENCTYPE="multipart/form-data" ACTION="avatar2.php" METHOD="POST">';
if(file_exists('avatar.jpg')){print'<img alt="" class="imgleft" src="avatar.jpg"/>';}
else{print'<img alt="" class="imgleft" src="no_pic.jpg"/>';}
print'Аватар <INPUT TYPE="file" NAME="avatar"/><br/><input id="submit" type="submit" name="submit" value="Прати"></FORM>';}
?>
<?
$user=$_SESSION['user'];
if(!$user){header("Location: login.php");
exit;}
else{
if (is_uploaded_file($HTTP_POST_FILES['avatar']['tmp_name'])) {
($_FILES['avatar']['error'] == 0)
or die($_FILES['avatar']['tmp_name'].': '.$errors[$_FILES['avatar']['error']]);
if ((($_FILES["avatar"]["type"] != "image/jpeg")) and $_FILES["avatar"]["type"] !="image/pjpeg"){print'Снимката не е JPEG!';exit;}
while(file_exists('avatar.jpg')) // iztrivame ako sashtetvuva
{
unlink('avatar.jpg');
}
if(copy($HTTP_POST_FILES['avatar']['tmp_name'], 'avatar.jpg')){print'OK';}
else{print'Error';}
}}
?>
<?
$user=$_SESSION['user'];
if(!$user){header("Location: login.php");
exit;}
else{
ini_set("memory_limit","128M");
if (is_uploaded_file($HTTP_POST_FILES['avatar']['tmp_name'])) {
($_FILES['avatar']['error'] == 0)
or die($_FILES['avatar']['tmp_name'].': '.$errors[$_FILES['avatar']['error']]);
if ((($_FILES["avatar"]["type"] != "image/jpeg")) and $_FILES["avatar"]["type"] !="image/pjpeg"){print'Снимката не е JPEG!';}
while(file_exists('avatar.jpg')) // iztrivame ako sashtetvuva
{
unlink('avatar.jpg');
}
// File and new size
$filename = $_FILES['avatar']['tmp_name'];
$source = imagecreatefromjpeg($filename);
$ThumbWidth=200; // kolko da e Width na avatara
list($width, $height) = getimagesize($filename);
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $ThumbWidth;
$newheight = $ThumbWidth/$imgratio;
}
else{
$newheight = $ThumbWidth;
$newwidth = $ThumbWidth*$imgratio;
}
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageJpeg ($thumb,'avatar.jpg');
ImageDestroy ($thumb);
ImageDestroy ($source);
}
print'OK<br/>Аватара е готов<br/><img src="avatar.jpg"/>';}
?>