problemčić sa uploadom i resizom slike

Pregledao sam gotovo više od pola postova i nikako da nađem riješenje za moj problemčić, u biti više je to ne znanje. :slight_smile:
Novi sam u php-u pa mi treba mala pomoć. Napisao sam kod za ubacivanje podataka o igraču u mysql i upload njegovih slika u određene foldere.
Htio bi da uploudam jednu sliku i da skripta promjeni sliku u dvije različite veličine te ih zatim spremi svaku u odgovarajući folder zajedno sa imenima tih slika u sql.

Ja sam to napravio ovako i radi svoj posao ali svakoj slici sam moram promjenit veličinu i zasebno ih uploudat. Evo djela koda, bio bih zahvalan kad bi mi rekli dali imam i koliko grešaka imam.

ostatak…pa zatim

<span class="syntaxdefault"></span><span class="syntaxkeyword">if(</span><span class="syntaxdefault">$pic</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">$sql&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"UPDATE&nbsp;momcad&nbsp;SET&nbsp;slika=('</span><span class="syntaxdefault">$pic</span><span class="syntaxstring">')&nbsp;WHERE&nbsp;igrac=('</span><span class="syntaxdefault">$igrac</span><span class="syntaxstring">')"</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span class="syntaxdefault">mysql_query</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$sql</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">$con</span><span class="syntaxkeyword">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{die(</span><span class="syntaxstring">'Doslo&nbsp;je&nbsp;do&nbsp;greske!'&nbsp;</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">mysql_error</span><span class="syntaxkeyword">());}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">/*echo&nbsp;"<div>slika&nbsp;za&nbsp;igraca&nbsp;$igrac&nbsp;je&nbsp;promjenjena</div>";*/<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*if(move_uploaded_file($_FILES['slika']['tmp_name'],&nbsp;$target))&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">if(</span><span class="syntaxdefault">move_uploaded_file</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$_FILES</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'slika'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'tmp_name'</span><span class="syntaxkeyword">],&nbsp;</span><span class="syntaxdefault">$target</span><span class="syntaxkeyword">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span class="syntaxstring">"velika&nbsp;slika&nbsp;"</span><span class="syntaxkeyword">.&nbsp;</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">$_FILES</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'uploadedfile'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'name'</span><span class="syntaxkeyword">]).&nbsp;</span><span class="syntaxstring">"&nbsp;je&nbsp;poslana,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span class="syntaxstring">"Doslo&nbsp;je&nbsp;do&nbsp;problema&nbsp;prilikom&nbsp;slanja&nbsp;slike."</span><span class="syntaxkeyword">;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span class="syntaxdefault">$slikam</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">$sql&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"UPDATE&nbsp;momcad&nbsp;SET&nbsp;slikam=('</span><span class="syntaxdefault">$slikam</span><span class="syntaxstring">')&nbsp;WHERE&nbsp;igrac=('</span><span class="syntaxdefault">$igrac</span><span class="syntaxstring">')"</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span class="syntaxdefault">mysql_query</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$sql</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">$con</span><span class="syntaxkeyword">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{die(</span><span class="syntaxstring">'Doslo&nbsp;je&nbsp;do&nbsp;greske!'&nbsp;</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">mysql_error</span><span class="syntaxkeyword">());}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">/*echo&nbsp;"<div>slika&nbsp;za&nbsp;igraca&nbsp;$igrac&nbsp;je&nbsp;promjenjena</div>";*/<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">if(</span><span class="syntaxdefault">move_uploaded_file</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$_FILES</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'slikam'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'tmp_name'</span><span class="syntaxkeyword">],&nbsp;</span><span class="syntaxdefault">$target2</span><span class="syntaxkeyword">))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span class="syntaxstring">"mala&nbsp;slika&nbsp;"</span><span class="syntaxkeyword">.&nbsp;</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">$_FILES</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'uploadedfile'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'name'</span><span class="syntaxkeyword">]).&nbsp;</span><span class="syntaxstring">"&nbsp;je&nbsp;poslana,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;informacije&nbsp;su&nbsp;dodane&nbsp;u&nbsp;tablicu"</span><span class="syntaxkeyword">;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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sp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault"></span> …ostatak koda

Uspio sam slici promjenit veličinu u dvije vrijednosti i spremiti ih u dva različita foldera i imena upist u bazu, samo sada je problem što te spremljenje slike su potpuno crne:frowning:
Može li mi netko pomoči?

našao sam gdje sam napravio propust

treba biti

ovako bi trebalo biti ako je slika jpeg format a kako bi mogao napraviti da se za vrijednost mjenja ovisno o formatu slike (jpeg,png, gif)
znači da za png format bude

a gif

znam da bi trebao prvo dobit extenziju slike sa

list ( $width, $height, $type, $attr) = getimagesize ( $slika_slanje );
pa onda usporedit tu dobivenu vrijednost sa jpg, png ili gif i ovisno o tome izbacit nešto kao $img = imagecreatefromjpeg($slika_slanje);
i $img uvrstit u

ali mi to nikako ne uspjeva…negdje griješim ali neznam gdje. Pomoć?

Prvo za polja koja su numericka ne stavljaj navodne znakove :

$sql = “UPDATE momcad SET igrac=(’$igrac’) WHERE id=(’$id’)”;

tipa kao sto si ovdje stavio ‘$id’ oko, jos jedna stvar sta ce ti zagrade ???
Kako treba izgledati (u slucaju da je $id kako sam pretpostavio numeric)

UPDATE momcad SET igrac = '$igrac WHERE id = $id;

MySQL pretpostavljam da guta ovakve ‘pizdarije’ al uci se odma pravilno pisati query-e.

Sto se tice uploadanja slika i slicno preporucio bi ti da koristis gotove i odlicne librarye za to :
http://phpthumb.gxdlabs.com/
Koristi ili GD ili Imagick (ovisno sto imas instaliratno i super radi posao). A cim stignem ako neko ne rijesi tvoj problem pogledacu sta ti stvara problem.

hvala, pripazit ću na to. :slight_smile:

hvala, pripazit ću na pisanje query-a. :slight_smile:
Ipak bi ja htio napisat ovo, znam da imam dosta grešaka u kodu ali ne želim uzeti već nečije gotove librarye, ovako barem mogu nešto naučit.
Predpostavljam i ovaj forum je tu kako bi svatko od svakoga nešto naučio.

Evo i cijeli dio koda koji obrađuje sliku

Itko? Za sada uredno obrađuje jpeg formate slika a ostale budu crne… :frowning:
Ne znam dali sam točno napisao ovaj dio za dohvačanje extenzije slike poslane na obradu i dali ga pravilno uspoređujem sa zadanim vrijednostima.

Zanimljiv pokušaj uporabe funkcije getimagesize(). Samo da si pogledao na ovoj stranici
http://www.php.net/manual/en/function.getimagesize.php
opis i primjere veazne uz korištenje ove funkcije vidio bi da nema šanse da ti ta stvar radi.

Naim funkcija getimagesize() vraća ove vrijednosti, po redu kako je napisano, kao array:

0 - širina
1 - visina
2 - tip slike
3 - string “visina=vvv širina=ššš”

Eto, ostatak koda nisam pogledao, ali bi ti moga pogledati na gore navedenom linku za primjere uporabe ove funkcije.

Hvala na pomoći i ukazivanju na grešake, počeo sam proučavati PHP prije nekih tjedan dva pa mi je svaka ukazana greška dobrodošla, pogledat ću ove primjere na php.net-u i popravit to.

Znam da je off topic ali evo možete pogledati što radim…

http://www.gsnk-mladost.hr

to mi je ujedno i prva stranica koju sam napravio…u biti još radim…

Našao sam problem funkcija getimagesize() kako je CreatifCode rekao vrača vrijednosti ovim redosljedom:

0 - širina
1 - visina
2 - tip slike
3 - string “visina=vvv širina=ššš”

i kada pomoću list() zatražim te vrijednosti mogu ih uspoređivat, ali sam tip slike funkcija getimagesize() ne vraća kao ekstenziju jpg, gif ili png već kao broj

1= gif
2=jpg
3=png

i onda to usporedim na ovaj način i sve radi. :slight_smile:

list($s, $v, $tip, $attr) = getimagesize( $slika_slanje );

						 if($tip == "2")
								{$tip = 'jpeg';}
						 if($tip == "1")
								{$tip = 'gif';}
						 if($tip == "3")
								{$tip = 'png';}

mozes i ovako

e i za ekstenziju imas

Hvala ti antelaca, iz ovog tvog primjera sam eto nešto i naučio. :slight_smile:
A ovo za funkciju image_type_to_extension() sam isto naša na php.net ali ne znam kako ona vrača vrijednost slike kao što nisam ni znao za getimagesize(), dali isto u brojevima?

Možeš li mi objasnit ili pokazat na nekom primjeru?

funkcija image_type_to_extension() prima dva parametra i na osnovu toga vraca ekstenziju slike
prvi parametar je integer i on je obavezan (to je tip slike)
drugi parametar je boolean (true,false) po defaultu je true i on određuje oce li funkcuija vratiti tocku sa ekstenzijom npr (.gif ili gif)

sa funkcijom getimagesize() dobijas niz sa vrijednostima slike

npr.

$info = getimagesize($slika)
print_r($info);

dobijemo nesto ovako

Array
(
[0] => 16
[1] => 16
[2] => 1
[3] => width=“16” height=“16”
[bits] => 5
[channels] => 3
[mime] => image/gif
)

$info[2] polje sadrzi tip slike, u ovom slucaju broj 1

1 = gif;
2 = jpg
3 = png

isto tako imas i predefinirane konstante i njihove vrijednosti

IMAGETYPE_GIF = 1
IMAGETYPE_JPEG = 2
IMAGETYPE_PNG = 3

znaci ista ti je stvar napisa ovo
$slika = ‘imeslike’ . image_type_to_extension(IMAGETYPE_GIF);
ili
$slika = ‘imeslike’ . image_type_to_extension(1);

varijabla $slika ima vrijednost (imeslike.gif)

ako napises ovo
$slika = ‘imeslike’ . image_type_to_extension($info[2]);

vratiti ce (imeslike.gif ili imeslike.jpg ili imeslike.png) ovisi o $info[2]

Sada mi je tek jasno ovo zašto si pisao IMAGETYPE_GIF,IMAGETYPE_JPEG i IMAGETYPE_PNG
u onom primjeru gore. Jer su to konstante i jednake su onim brojevima koje getimagesize() vrača za određenu sliku.
Ovako ukratko i jasno objašnjenje nebih dobio ni na faksu.
Hvala ti još jednom.


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja