Autor Zpráva
Kiwwik
Profil *
<?php  
$template = $_FILES['foto']['tmp_name'];
$name_foto = 1; 
$name_foto1 = md5($name_foto.$user_id); 
$type_foto = $_FILES['foto']['type']; 

$type_explode = explode('/', $type_foto);
$type = $type_explode['1'];
$koncovka    ='.'.strtolower($type[0].$type[1].$type[3]); 

$name = $name_foto1.$koncovka;

$uploaddir = "./img/fotos/fotoalbum-gross/";
$uploadfile = $uploaddir . basename($name);


$size = $_FILES['foto']['size'];

$album_id = $_POST['album_id'];
$beschreibung = $_POST['beschreibung'];

$maxdatasize_n = 4*1024;
$maxdatasize = $maxdatasize_n*1024;

if ($type_foto == "image/jpeg"){
if ($size < $maxdatasize){


if (copy($template, $uploadfile)){

// erstellen von thumbs
$dest = "./img/fotos/fotoalbum-mini/".$name."";
$dest1 = "./img/fotos/fotoalbum-klein/".$name."";
$dest2 = "./img/fotos/fotoalbum-vorschau/".$name."";
$dest3 = "./img/fotos/fotoalbum-forum/".$name."";

thumb_1($uploadfile, $dest, '60', '60');
thumb_1($uploadfile, $dest1, '150', '120');
thumb($uploadfile, $dest2, '400');
thumb($uploadfile, $dest3, '300');

// sql
$time = time();
$sql_foto_insert=mysql_query("INSERT INTO fotos (user_id, album_id, datei, beschreibung, datum) VALUES ('$user_id_session', '$album_id', '$name', '$beschreibung', '$time')") or die (mysql_error()); 




}else{

}

}else{

}
}else{

}


ahojte mam tento kod pre upload obrazkov ale neviem preco ked si niaky obrazok uploadnem ze sa niekedy uploadne cierny obrazok ?
Kiwwik
Profil *
prepacte v tomto kode by mala byt chyba

function thumb_1 ($sourcename, $targetname, $targetdim_0, $targetdim_1) {
	$targetdim[0] = $targetdim_0;		$targetdim[1] = $targetdim_1;
	
	$sourcedim = getimagesize($sourcename);
	if (($sourcedim[0]/$targetdim[0]) > ($sourcedim[1]/$targetdim[1])):
		$sourcecut[1] = 0;
		$sourcecut[0] = round(($sourcedim[0] - $sourcedim[1]/$targetdim[1] * $targetdim[0]) / 2);
		$sourcedim[0] = round($sourcedim[1]/$targetdim[1] * $targetdim[0]);
	else:
		$sourcecut[0] = 0;
		$sourcecut[1] = round(($sourcedim[1] - $sourcedim[0]/$targetdim[0] * $targetdim[1]) / 2);
		$sourcedim[1] = round($sourcedim[0]/$targetdim[0] * $targetdim[1]);
	endif;

	$source = imagecreatefromjpeg($sourcename);
	$target = imagecreatetruecolor($targetdim[0],$targetdim[1]);
	imagecopyresampled($target,$source,0,0,$sourcecut[0],$sourcecut[1],$t argetdim[0],$targetdim[1],$sourcedim[0],$sourcedim[1]);
	imagejpeg($target,$targetname,80);
	imagedestroy ($source);
	imagedestroy ($target);
}
Kiwwik
Profil *
uz viem ale neviem ako to zmenit ked user uploaduje obrazok prilyz maly tak sa thumb nevytvori ale preco ?
horava2
Profil
Zkus tohle :

<input type="file" name="fupload">
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
<tr>
<td><input type="submit" VALUE="Nahrát" style="font-weight:bold;"></td>
</tr>
</table>
</form>



<?php
if (isset($_FILES['fupload']))
  {
    if($_FILES['fupload']['type']=="application/octet-stream"){
    echo "Soubory s příponou PHP jsou zakázány!";
    echo "Soubory s příponou PHP jsou zakázány!";
  	}elseif($_FILES['fupload']['size'] > 300*1024){
  		echo "Soubor přesahuje maximální limit 300kB!";
    }else{
    $slozka = "./fotky"; //cesta k adresari, kam se maji fotky nahrat
    $cil = $slozka . "/" .$_FILES['fupload']['name'];
    $nazev_souboru = $_FILES['fupload']['tmp_name'];
    $copy = move_uploaded_file($nazev_souboru, $cil)
      or die ("Přenesený soubor nelze zkopírovat");
    chmod ($cil, 0644);
    if($copy == true){
      echo " " .$_FILES['fupload']['name']. " <b>Fotka úspěšně vložena.</b>\n<br><a href=\"$cil\"></a>";
    }else{
      echo "Fotka nebyla přidána.\nPočet chyb: " . $_FILES['fupload']['error'];
    }
    }
  }
?>

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0