Autor | Zpráva | ||
---|---|---|---|
Kiwwik Profil * |
#1 · Zasláno: 3. 12. 2008, 19:26:40
<?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 * |
#2 · Zasláno: 3. 12. 2008, 19:27:28
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 * |
#3 · Zasláno: 3. 12. 2008, 20:38:18
uz viem ale neviem ako to zmenit ked user uploaduje obrazok prilyz maly tak sa thumb nevytvori ale preco ?
|
||
Časová prodleva: 3 dny
|
|||
horava2 Profil |
#4 · Zasláno: 6. 12. 2008, 11:33:34 · Upravil/a: horava2
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']; } } } ?> |
||
Časová prodleva: 15 let
|
0