Mam skrypt dodawania obrazków :
laduj.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
if (isset ($_POST["submit"])) {
include ("upload.php");
$image = new Image($_FILES['file']['name']);
$image -> PicDir = "uploads/";
$image -> TmpName = $_FILES['file']['tmp_name'];
$image -> newHeight = '100';
$image -> newWidth = '100';
$image -> FileSize = $_FILES['file']['size']; $image -> FileType = $_FILES['file']['type'];
//$image -> Save(); //use this if you wish images without resizing
$image -> Resize ();
} else {
?><?php
}
?>
<form name="form" action="
<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="40">
<input type="submit" name="submit" value="dodaj">
</form>
Sam nie pisałem tych skryptów dlatego mam z tym problem.. Więc stąd moje pytania.. po to jest
<?php
}
?>
w 1 pliku ?
Dlaczego obrazek nie zawsze się pojawia ?
Dlaczego znowu wyskakuje po załadowaniu zdjęcia i wyświetleniu informacji pasek ładowania obrazka na samym dole ?
Jak podnieść infomację o załadowanym obrazku do góry ?
Wiem, że sporo tego ale z góry dzięki !

I drugi skrypt..
i upload.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
class Image {
var $FileName;
var $FileSize;
var $FileType;
var $AllowedExtentions = array ("image/png", "image/gif", "image/jpeg", "image/jpg"); var $newWidth; // new width
var $newHeight; //new height
var $TmpName;
var $PicDir; //store uploaded images
var $MaxFileSize = 500000; //kbytes
var $ImageQuality = 75; // image compression (max value 100)
function GetInfo() {
$out=' <br><br>Zdjęcie zostało dodane!<br>
Name: '.$this->FileName.'<br>
file size: '.$this->FileSize.' byte<br>
file type: '.$this->FileType.'<br>
<img src=' . dirname($_SERVER['PHP_SELF']) . '/' . $this->PicDir . $this->FileName . '><br><br>';
return $out;
}
function Image($FileName)
{
$this->FileName=$FileName;
}
function GetFileExtention ($FileName) {
if (in_array ($this->FileType, $this -> AllowedExtentions
)) { return true;
} else {
return false;
}
}
function ExistFile () {
$fileexist = $_SERVER['DOCUMENT_ROOT'] .
'/' . $this->PicDir .
$this->FileName;
}
function GetError ($error) {
switch ($error) {
case 0 :
echo "Złe rozszerzenie pliku <b>$this->FileType</b>! Dopuszczalne typy: .jpg, .jpeg, .gif, .png <b>$this->FileName</b><br>"; break;
case 1 :
echo "Zdjęcie <b>$this->FileSize</b> jest za duże.<br>"; break;
case 2 :
echo "Proszę wybrać zdjęcie.<br>"; break;
case 3 :
echo "Error: File <b>$this->FileName</b> already exist!<br>"; break;
}
}
function Resize () {
if (empty ($this->TmpName)) {echo $this -> GetError
(2
);} else if ($this->FileSize > $this->MaxFileSize) {echo $this -> GetError
(1
);} else if ($this -> GetFileExtention
($this->FileName) == false) {echo $this -> GetError
(0
);} else if ($this -> ExistFile
()) {echo $this -> GetError
(3
);}
else {
$ext = explode(".",$this->FileName);
// Get new sizes
list
($width_orig, $height_orig) = getimagesize($this->TmpName);
$ratio_orig = $width_orig/$height_orig;
if ($this->newWidth/$this->newHeight > $ratio_orig) {
$this->newWidth = $this->newHeight*$ratio_orig;
} else {
$this->newHeight = $this->newWidth/$ratio_orig;
}
$normal = imagecreatetruecolor($this->newWidth, $this->newHeight);
if ($ext == "jpg") { $source = imagecreatefromjpeg($this->TmpName); }
else if ($ext == "gif") { $source = imagecreatefromgif ($this->TmpName); }
else if ($ext == "png") { $source = imagecreatefrompng ($this->TmpName); }
imagecopyresampled($normal, $source, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $width_orig, $height_orig);
if ($ext == "jpg") {
//ob_start();
imagejpeg($normal, "$this->PicDir/$this->FileName", "$this->ImageQuality");
//$binaryThumbnail = ob_get_contents();
//ob_end_clean();
}
else if ($ext == "gif") { imagegif ($normal, '', "$this->ImageQuality"); }
else if ($ext == "png") { imagepng ($normal, '', "$this->ImageQuality"); }
imagedestroy($source);
}
}
function Save() {
if (empty ($this->TmpName)) {echo $this -> GetError
(2
);} else if ($this->FileSize > $this->MaxFileSize) {echo $this -> GetError
(1
);} else if ($this -> GetFileExtention
($this->FileName) == false) {echo $this -> GetError
(0
);} else if ($this -> ExistFile
()) {echo $this -> GetError
(3
);}
else {
copy($this->TmpName,$this->PicDir.$this->FileName);
}
}
}
?>