Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
upload slika - php

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 09:59    Post subject: upload slika - php Add user to your forum ignore list Reply with quote

zasad sam stavila da mi se na webu uploada samo jpeg format slika ali imam nekih slučajeva da slike koje su bile recimo u bmp formatu pa ih u ps-u preacim u jpeg, stavim na RGB ne kuži ko jpeg već mi javlja da format nije taj.. why?

pitanje: koje sve slikovne formate bi bilo pametno staviti kao dopuštene za upload slika u cms-u za news-e? koji savjet ili link je dobrodošao...

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 30.12.2005 10:13    Post subject: Add user to your forum ignore list Reply with quote

koje? pa one podrzane brozerima....jpg, gif i png prouci getimagesize funkciju ak nisi vec

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 10:24    Post subject: Add user to your forum ignore list Reply with quote

upravo gledam, valjda će kad dodam još i gif i png format raditi i ove slike koje za sad ne želi uploadati

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 30.12.2005 10:27    Post subject: Add user to your forum ignore list Reply with quote

hm...pri uploadu ne bi trebalo biti nekih problema s bilo kakvim formatom...provjeru trebas raditi kad je file vec na serveru.

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 11:04    Post subject: Add user to your forum ignore list Reply with quote

sad primjećujem da u ovoj reszie funkciji ima proračun offseta a ja to u svom kodu nisam napravila i možda je u tome štos
čemu uopće služi i što predstavlja taj offset?

ma evo i kod da znate što to radim:

if ($_FILES['slika']['type'] == "image/jpeg" || $_FILES['slika']['type'] == "image/gif" || $_FILES['slika']['type'] == "image/png") {
list($w, $h, $imagetype)=getimagesize($filename);
switch ($_FILES['slika']['type']) {
case 1:
$srcImage = imageCreateFromGif($_FILES['slika']['name']);
break;
case 2:
$srcImage = imageCreateFromJpeg($_FILES['slika']['name']);
break;
case 3:
$srcImage = imageCreateFromPng($_FILES['slika']['name']);
break;
}
if($w>350) {
$nw=350;
$percent= $nw/$w;
$nh=$h*$percent;
} else {
$nw=$w;
$nh=$h;
}
if ($w>100) {
$tw=100;
$percent= $tw/$w;
$th=$h*$percent;
} else {
$tw=$w;
$th=$h;
}

$small = imagecreatetruecolor($tw, $th);
$large = imagecreatetruecolor($nw, $nh);

// Resample
imagecopyresampled($small, $srcImage, 0, 0, 0, 0, $tw, $th, $w, $h);
imagecopyresampled($large, $srcImage, 0, 0, 0, 0, $nw, $nh, $w, $h);

// Output
imagejpeg($small, '../path/'.$_FILES['slika']['name'],100);
imagejpeg($large, '../path/'.$_FILES['slika']['name'],100);
unlink('../path/'.$_FILES['slika']['name']);

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 30.12.2005 11:25    Post subject: Add user to your forum ignore list Reply with quote

hm....a ne bi radje imala genericku funkciju za upload....i posebnu funkciju za ostalo...iskreno ovo je prva ovakva implementacija...da vidim da netko proslijedjujje $_FILES array direktno u funkciju Shocked

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 11:32    Post subject: Add user to your forum ignore list Reply with quote

kod ovakvih kao ja je svašta moguće Cool
ovo je odlično radilo za upload jpegova s iznimkom tih koji su doiveni konvertiranjem iz bmp-a, ali sad kad sam stavila da radi i za gif i png javlja neke greške pa ću ipak probati s tomm vašom funkcijom
thx anyway
evo sad radi, bila sam zakomentirala koji redak viška i ovo s arrayima je bilo totalno krivo

if ($_FILES['slika']['type'] == "image/jpeg" || $_FILES['slika']['type'] == "image/gif" || $_FILES['slika']['type'] == "image/png") {
copy ($_FILES['slika']['tmp_name'], "../images/novosti/".$_FILES['slika']['name']) or die ("Could not copy");
$filename='../path/'.$_FILES['slika']['name'];
list($w, $h, $imagetype)=getimagesize($filename);
switch ($imagetype) {
case 1:
$srcImage = imageCreateFromGif($filename);
break;
case 2:
$srcImage = imageCreateFromJpeg($filename);
break;
case 3:
$srcImage = imageCreateFromPng($filename);
break;
}
/* copy ($_FILES['slika']['tmp_name'], "../path/".$_FILES['slika']['name']) or die ("Could not copy"); */
/* $filename='../path/'.$_FILES['slika']['name'];*/
/* list($w, $h)=getimagesize($srcImage);*/
if($w>350) {
$nw=350;
$percent= $nw/$w;
$nh=$h*$percent;
} else {
$nw=$w;
$nh=$h;
}
if ($w>100) {
$tw=100;
$percent= $tw/$w;
$th=$h*$percent;
} else {
$tw=$w;
$th=$h;
}

$small = imagecreatetruecolor($tw, $th);
$large = imagecreatetruecolor($nw, $nh);

// Resample
imagecopyresized($small, $srcImage, 0, 0, 0, 0, $tw, $th, $w, $h);
imagecopyresized($large, $srcImage, 0, 0, 0, 0, $nw, $nh, $w, $h);

// Output
imagejpeg($small, '../pathi/small/'.$_FILES['slika']['name'],100);
imagejpeg($large, '../path/large/'.$_FILES['slika']['name'],100);
unlink('../path/'.$_FILES['slika']['name']);

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 12:24    Post subject: Add user to your forum ignore list Reply with quote

ova skripta radi i uploada sve ove formate normalno iz FF-a ali u exploreru javlja da format nije dozvoljen, tj. ne prođe onaj prvi uvjet iz koda.
zašto sad to?

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 30.12.2005 12:27    Post subject: Add user to your forum ignore list Reply with quote

nemoj se pouzdavati u to sto ti salje browser....zato sam ti i rekao da pogledas getimagesize funkciju....jer ona vraća pravi tip slika Rolling Eyes

i pogledaj funkciju move_uploaded_file trebala bi tu funkciju koristiti umjesto copy

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 30.12.2005 12:45    Post subject: Add user to your forum ignore list Reply with quote

sad radi, hvala ti od srca Wink

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 30.12.2005 12:49    Post subject: Add user to your forum ignore list Reply with quote

np Wink

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group